enhance (cost + performance) adding weights to graphs derived from confidence score to use weighted bfs#399
Open
akhiljns wants to merge 1 commit intosafishamsi:v4from
Open
enhance (cost + performance) adding weights to graphs derived from confidence score to use weighted bfs#399akhiljns wants to merge 1 commit intosafishamsi:v4from
akhiljns wants to merge 1 commit intosafishamsi:v4from
Conversation
…hted bfs to traverse using cost attribute
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Weighted Graph Traversal and Pathfinding
Changes
build.pyEvery edge now gets a
costattribute derived fromconfidence_score:Examples:
EXTRACTED=1.0INFERRED@0.8=1.25AMBIGUOUS@0.2=5.0serve.pyTwo new algorithms were added:
_weighted_bfs()A priority-queue-based BFS using
heapqthat explores high-confidence edges first within the depth limit._weighted_shortest_path()Uses
nx.dijkstra_path()with thecostattribute.MCP tools
query_graphnow acceptsmode: "weighted"alongside"bfs"and"dfs".shortest_pathnow acceptsweighted: truefor Dijkstra-based traversal.cluster.pycluster()and_partition()now acceptweighted=True.When enabled:
confidence_scoreis copied into theweightedge attribute for Leiden/Louvain clustering.EXTRACTEDedges (1.0) bind communities tighter thanINFERREDedges (0.6–0.9) orAMBIGUOUSedges (0.1–0.3).main.pyNew CLI flags:
graphify query "..." --weighted— priority-queue BFS.graphify path "A" "B" --weighted— Dijkstra shortest path.Help text has also been updated for both commands.
How It Works
graphify query "authentication" --weightedExplores high-confidence edges first.
Finds the most trustworthy path, not necessarily the shortest.
The weighted path avoids low-confidence shortcuts. For example, an
AMBIGUOUS1-hop edge with cost5.0is skipped in favor of a 3-hopEXTRACTEDpath with total cost3.0.