Procs
proc extendWithEdges[N, E](self: var Graph[N, E]; iterable: openArray[(int, int)])
- Source Edit
proc extendWithEdges[N, E](self: var Graph[N, E]; iterable: openArray[(int, int, E)])
-
Extend the graph from an iterable of edges.
Node weights N are set to default values. Edge weights E may either be specified in the list, or they are filled with default values.
Nodes are inserted automatically to match the edges.
Source Edit proc graphFromEdges[N, E](iterable: openArray[(int, int)]): Graph[N, E]
- Source Edit
proc graphFromEdges[N, E](iterable: openArray[(int, int, E)]): Graph[N, E]
-
Create a new Graph from an iterable of edges.
Node weights N are set to default values. Edge weights E may either be specified in the list, or they are filled with default values.
Nodes are inserted automatically to match the edges.
import graph let graph2 = graphFromEdges[int, int](@[ (0, 1), (0, 2), (0, 3), (1, 2), (1, 3), (2, 3)])
Source Edit proc updateEdge[N, E](self: var Graph[N, E]; a, b: Natural; weight: E)
-
Add or update an edge from a to b. If the edge already exists, its weight is updated.
Return the index of the affected edge.
Computes in O(e') time, where e' is the number of edges connected to a.
Source Edit
Iterators
iterator edges[N, E](self: Graph[N, E]; a: Natural; dir = Outgoing): (int, E)
-
Return all neighbors that have an edge between them and a, in the specified direction.
Neighbors are listed in reverse order of their addition to the graph, so the most recently added edge's neighbor is listed first.
Source Edit iterator neighbors[N, E](self: Graph[N, E]; a: Natural; dir = Outgoing): int
-
Return all neighbors that have an edge between them and a, in the specified direction.
Neighbors are listed in reverse order of their addition to the graph, so the most recently added edge's neighbor is listed first.
Source Edit