Graphs
Terminology
node
A point or vertice on the graph. (Also stated as V)
edge
The connection between two nodes. (Also stated as E)
connected
When every node has a path to another node.
cycle
When you start at , follow the links, and end back at . (Can't be only 2 nodes)
acyclic
A graph that contains no cycles.
directed
When there is a direction to the connections. (This helps making asymetric connections, Ex.: but )
undirected
Not directed. (The default) (Ex.: has the same weight as
weighted
The edges have a weight associated with them.
dag
Directed, acyclic graph.
Representing Graphs
Adjacent List
A list, where each main index of the list points to a node of the graph, describing its connections to the other nodes.
Traversing/Searching with BFS
BFSTraversing/Searching with DFS
DFSEasier to preserve the path.
Adjacent Matrix
A matrix, where each main index of the first array points to a node of the graph, describing in a second array the weights to the other nodes or zero if there is no connection.
Uses more memory, since it represents non-existent connections with zero.
Traversing/Searching with BFS
BFSLast updated