2025-11-10
linksV of vertices and a set E of edges:edge in E connects two of the vertices in VNode
vertexVertices and edges can be labeled or unlabeled:weights (known as a weighted graph)
Unlabeled, labeled, and weighted graphs
v to another if there is an edge connecting the two vertices:
neighborspath is a sequence of edges that allows one vertex to be reached from another vertex in a graphreachable from another vertex if there is a path between the two:
Length of a path is the number of edges on the pathconnected if there is a path from each vertex to every other vertexcomplete if there is an edge from each vertex to every other vertexsubgraph consisting of the set of vertices that are reachable from a given vertexDiagraph): Edges have a direction, going from one vertex to another (such as one-way streets).
directed edge
source vertex and a destination vertexDAG)adjacency matrix and adjacency listAssume that a graph has N vertices labeled 0, 1, …, N − 1, and then the following applies:
The adjacency matrix for the graph is a grid G with N rows and N columns
The cell G[i][j] contains 1 if there is an edge from vertex i to vertex j in the graph; otherwise, there is no edge, and that cell contains 0
N vertices labeled 0, 1, …, N − 1, and then the following applies:
N linked listsith linked list contains a node for vertex j if and only if there is an edge from vertex i to vertex jN = number of vertices and M = number of edges, then the following applies: