Iterate over all the vertices connectd to context
vertex
Makes a connection between options.a
and one or more nodes in options.b
.
Same as connectWithEdges but only the Graph is returned.
Connects A with B, returning the changed graph and created edge. If the connection already exists, the original graph & edge is returned.
Makes a connection between options.a
and one or more nodes in options.b
.
Same as connect but graph and edges are returned.
Return a string representation of the graph for debug inspection
Gets the connection, if it exists between a
and b
in graph
.
If it doesn't exist, undefined is returned.
Use hasConnection for a simple true/false if edge exists.
Returns true/false if there is a connection between a
and b
in graph
.
Use getConnection if you want to the edge.
Undirected graphs
Graph vertices (ie. nodes) connect to each other along edges. Unlike a directed graph, nodes are always mutually connected.
Example: Creating an undirected graph where vertex 0 connects to 1, 2 & 3; 2 connects to 1
Graphs do not store data directly, only the relation between vertices. Each vertex has an id, so to associate data, use a map along with the graph.