Members
(constant) Tuple
Returns an immutable tuple (implemented as Immutable.List) of the arguments.
(constant) toDirected
Returns a new directed graph with the same vertices and edges as the
- Source:
(constant) toUndirected
Returns a new undirected graph with the same vertices and edges as the
- Source:
Methods
bfsEdges(graph, v)
Generator that yields the edges in the graph from a BFS starting at v.
Stops once all vertices have been visited.
Parameters:
| Name | Type | Description |
|---|---|---|
graph |
GenericGraph.<V, E> | the graph to traverse. |
v |
V | the vertex to start the BFS at. |
- Source:
dfsEdges(graph, v)
Generator that yields the edges in the graph from a DFS starting at v.
Parameters:
| Name | Type | Description |
|---|---|---|
graph |
GenericGraph.<V, E> | the graph to traverse. |
v |
V | the vertex to start the DFS at. |
- Source:
edgeBfs(graph, v)
Similar to bfs_edges, in that it returns edges in BFS order from a source.
However, it differs in that it stops
once all the edges in the connected component containing v have been
visited.
Parameters:
| Name | Type | Description |
|---|---|---|
graph |
GenericGraph.<V, E> | the graph to traverse. |
v |
V | the vertex to start the BFS at. |
- Source:
hasPath(graph, source, target) → {boolean}
Determines if there is a path from v to w.
Parameters:
| Name | Type | Description |
|---|---|---|
graph |
GenericGraph.<V, E> | the graph to search. |
source |
V | |
target |
V |
- Source:
Returns:
true if there is a path from v to w, false otherwise.
- Type
- boolean
isDirectedAcyclicGraph(graph) → {boolean}
Determines if the graph is a directed acyclic graph.
Parameters:
| Name | Type | Description |
|---|---|---|
graph |
GenericGraph.<V, E> | the graph to check. |
- Source:
Returns:
true if the graph is a directed acyclic graph,
false otherwise.
- Type
- boolean
shortestPath(graph, v, w) → {Array.<V>}
Computes the shortest path from v to w. If no such path exists,
raises an error.
Parameters:
| Name | Type | Description |
|---|---|---|
graph |
GenericGraph.<V, E> | the graph to search. |
v |
V | the source vertex. |
w |
V | the destination vertex. |
- Source:
Throws:
-
if no path exists from v to w.
- Type
- NoPathExistsError
Returns:
an array of vertices representing the shortest path from
v to w.
- Type
- Array.<V>
(generator) topologicalGenerations(graph)
A copy of networkx's topological generations algorithm.
Parameters:
| Name | Type | Description |
|---|---|---|
graph |
GenericGraph.<V, E> | the graph to traverse. |
- Source:
- See:
topologicalSort(graph)
Returns a topological sort of the graph.
Parameters:
| Name | Type | Description |
|---|---|---|
graph |
GenericGraph.<V, E> | the graph to sort. |
- Source:
Throws:
-
CycleError if the graph is cyclic.
-
UnfeasibleError if the graph is not directed.