Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -272,10 +272,15 @@ graphblas_algorithms.nxapi
│ │ └── floyd_warshall_predecessor_and_distance
│ ├── generic
│ │ ├── average_shortest_path_length
│ │ └── has_path
│ │ ├── has_path
│ │ └── shortest_path
│ ├── unweighted
│ │ ├── all_pairs_shortest_path
│ │ ├── all_pairs_shortest_path_length
│ │ ├── predecessor
│ │ ├── single_source_shortest_path
│ │ ├── single_source_shortest_path_length
│ │ ├── single_target_shortest_path
│ │ └── single_target_shortest_path_length
│ └── weighted
│ ├── all_pairs_bellman_ford_path_length
Expand Down
10 changes: 10 additions & 0 deletions _nx_graphblas/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ def get_info():
"adamic_adar_index",
"adjacency_matrix",
"all_pairs_bellman_ford_path_length",
"all_pairs_shortest_path",
"all_pairs_shortest_path_length",
"ancestors",
"average_clustering",
Expand Down Expand Up @@ -139,6 +140,7 @@ def get_info():
"pagerank",
"partition_quality",
"periphery",
"predecessor",
"preferential_attachment",
"radius",
"reciprocity",
Expand All @@ -147,8 +149,11 @@ def get_info():
"s_metric",
"schultz_index",
"score_sequence",
"shortest_path",
"single_source_bellman_ford_path_length",
"single_source_shortest_path",
"single_source_shortest_path_length",
"single_target_shortest_path",
"single_target_shortest_path_length",
"square_clustering",
"symmetric_difference",
Expand Down Expand Up @@ -191,6 +196,7 @@ def get_info():
_additional_docs = {
# BEGIN: additional_docs
"all_pairs_bellman_ford_path_length": "Raises OverflowError rather than add integer weights where the number of nodes times the\nheaviest absolute weight reaches 2**62, as a length could then pass 2**63.",
"all_pairs_shortest_path": "Each path is a shortest path, but where there are several it may not be NetworkX's. Beside\neach node a path holds that node's neighbor one step nearer the path's fixed end (the\nsource, or the target) that is first in node order; NetworkX's holds the one its walk came\nfrom first. The nodes come by level from the fixed end, each level in node order.",
"average_shortest_path_length": 'A `method` other than None, "unweighted", "dijkstra" and "bellman-ford" is left to\nNetworkX. Lengths are Bellman-Ford\'s, with `method="dijkstra"` too, so a negative edge\nwithout a negative cycle is answered where NetworkX\'s Dijkstra raises\n"Contradictory paths found".',
"bellman_ford_path": "Raises OverflowError rather than add integer weights where the number of nodes times the\nheaviest absolute weight reaches 2**62, as a length could then pass 2**63.",
"bellman_ford_path_length": "Raises OverflowError rather than add integer weights where the number of nodes times the\nheaviest absolute weight reaches 2**62, as a length could then pass 2**63.",
Expand Down Expand Up @@ -225,10 +231,14 @@ def get_info():
"local_efficiency": "The cost is the breadth-first levels times the chunks of walks, so a node whose\nneighbors induce long paths (the hub of a wheel) is no faster than in NetworkX; the\nmemory stays bounded.",
"negative_edge_cycle": "Raises OverflowError rather than add integer weights where the number of nodes times the\nheaviest absolute weight reaches 2**62, as a length could then pass 2**63.",
"periphery": '`usebounds` bounds the eccentricities on an undirected graph whose lengths are integers;\nelsewhere every one is computed. The null graph is left to NetworkX.\nLengths are Bellman-Ford\'s, so a negative edge without a negative cycle is answered where\nNetworkX\'s Dijkstra raises "Contradictory paths found".\nRaises OverflowError rather than add integer weights where the number of nodes times the\nheaviest absolute weight reaches 2**62, as a length could then pass 2**63.',
"predecessor": "Each node's predecessors are NetworkX's, all of its neighbors one step nearer the\nsource, but in node order rather than in the order NetworkX's walk reaches them. The\nnodes come by level, each level in node order.",
"radius": '`usebounds` bounds the eccentricities on an undirected graph whose lengths are integers;\nelsewhere every one is computed. The null graph is left to NetworkX.\nLengths are Bellman-Ford\'s, so a negative edge without a negative cycle is answered where\nNetworkX\'s Dijkstra raises "Contradictory paths found".\nRaises OverflowError rather than add integer weights where the number of nodes times the\nheaviest absolute weight reaches 2**62, as a length could then pass 2**63.',
"reverse": "Edge weights come back in the one type their matrix holds: mixed ints and floats, or\n`np.uint64` beside signed ints, as floats (1 as 1.0), bools mixed with numbers as\nnumbers (True as 1 or 1.0), and NumPy scalars as Python numbers. A mix that would\nchange a value, such as an int past 2**53 beside a float, is left to NetworkX.",
"schultz_index": 'A graph with a node named "weight" is left to NetworkX.\nRaises OverflowError rather than add integer weights where the number of nodes times the\nheaviest absolute weight reaches 2**62, or where the sum over one node\'s targets could\nreach 2**63.',
"shortest_path": "Unweighted: a call with `weight` is left to NetworkX, as is a path between two nodes of\na NetworkX graph, since NetworkX's search from both ends costs less than a conversion.\nEach path is a shortest path, but where there are several it may not be NetworkX's. Beside\neach node a path holds that node's neighbor one step nearer the path's fixed end (the\nsource, or the target) that is first in node order; NetworkX's holds the one its walk came\nfrom first. The nodes come by level from the fixed end, each level in node order.\nOn a graph of this backend's own, the path between two nodes joins a walk out of\neach end where they first meet, which may be at another node than NetworkX's.",
"single_source_bellman_ford_path_length": "Raises OverflowError rather than add integer weights where the number of nodes times the\nheaviest absolute weight reaches 2**62, as a length could then pass 2**63.",
"single_source_shortest_path": "Each path is a shortest path, but where there are several it may not be NetworkX's. Beside\neach node a path holds that node's neighbor one step nearer the path's fixed end (the\nsource, or the target) that is first in node order; NetworkX's holds the one its walk came\nfrom first. The nodes come by level from the fixed end, each level in node order.",
"single_target_shortest_path": "Each path is a shortest path, but where there are several it may not be NetworkX's. Beside\neach node a path holds that node's neighbor one step nearer the path's fixed end (the\nsource, or the target) that is first in node order; NetworkX's holds the one its walk came\nfrom first. The nodes come by level from the fixed end, each level in node order.",
"union": "Edge weights come back in the one type their matrix holds: mixed ints and floats, or\n`np.uint64` beside signed ints, as floats (1 as 1.0), bools mixed with numbers as\nnumbers (True as 1 or 1.0), and NumPy scalars as Python numbers. A mix that would\nchange a value, such as an int past 2**53 beside a float, is left to NetworkX.",
"volume": "Raises OverflowError rather than add integer weights whose absolute values sum to 2**63\nor more, or to 2**63 over the most times `S` names one node.",
"wiener_index": 'Lengths are Bellman-Ford\'s, so a negative edge without a negative cycle is answered where\nNetworkX\'s Dijkstra raises "Contradictory paths found".\nRaises OverflowError rather than add integer weights where the number of nodes times the\nheaviest absolute weight reaches 2**62, or where the sum over one node\'s targets could\nreach 2**63.',
Expand Down
24 changes: 24 additions & 0 deletions _nx_graphblas/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,20 @@
"A precomputed `core_number`, or a `k` that is not a real number, is left to NetworkX."
)

# A graph can have several shortest paths between two nodes. NetworkX's choice follows the order
# each node's edges were added, which a matrix does not keep.
_ONE_SHORTEST_PATH = (
"Each path is a shortest path, but where there are several it may not be NetworkX's. Beside\n"
"each node a path holds that node's neighbor one step nearer the path's fixed end (the\n"
"source, or the target) that is first in node order; NetworkX's holds the one its walk came\n"
"from first. The nodes come by level from the fixed end, each level in node order."
)

# Prose NetworkX shows under a function's documentation, for behaviour its docstring does not
# describe.
_ADDITIONAL_DOCS = {
"all_pairs_bellman_ford_path_length": _PATH_OVERFLOW,
"all_pairs_shortest_path": _ONE_SHORTEST_PATH,
"average_shortest_path_length": (
'A `method` other than None, "unweighted", "dijkstra" and "bellman-ford" is left to\n'
'NetworkX. Lengths are Bellman-Ford\'s, with `method="dijkstra"` too, so a negative edge\n'
Expand Down Expand Up @@ -173,10 +183,24 @@
),
"negative_edge_cycle": _PATH_OVERFLOW,
"periphery": _ECCENTRICITY_BOUNDS,
"predecessor": (
"Each node's predecessors are NetworkX's, all of its neighbors one step nearer the\n"
"source, but in node order rather than in the order NetworkX's walk reaches them. The\n"
"nodes come by level, each level in node order."
),
"radius": _ECCENTRICITY_BOUNDS,
"schultz_index": 'A graph with a node named "weight" is left to NetworkX.\n'
+ _LENGTH_SUM_OVERFLOW,
"shortest_path": (
"Unweighted: a call with `weight` is left to NetworkX, as is a path between two nodes of\n"
"a NetworkX graph, since NetworkX's search from both ends costs less than a conversion.\n"
+ _ONE_SHORTEST_PATH
+ "\nOn a graph of this backend's own, the path between two nodes joins a walk out of\n"
"each end where they first meet, which may be at another node than NetworkX's."
),
"single_source_bellman_ford_path_length": _PATH_OVERFLOW,
"single_source_shortest_path": _ONE_SHORTEST_PATH,
"single_target_shortest_path": _ONE_SHORTEST_PATH,
"volume": _SUM_OVERFLOW + ", or to 2**63 over the most times `S` names one node.",
"wiener_index": _NEGATIVE_EDGES + "\n" + _LENGTH_SUM_OVERFLOW,
}
Expand Down
Loading
Loading