Graph Definitions
A few more graph definitions
Now that we have the basics of what a graph is, here are a few more terms that might come in handy while discussing graphs.
Term Definition
Edge A single connection between two vertices
Adjacent Two vertices are adjacent if there is an edge connecting them
Connected A graph is connected if every vertex has a path to all other vertices. (Also describes two nodes if there is an edge connecting them)
Neighbor Two vertices are neighbors if there is an edge connecting them
Set of neighbors The set of all nodes that are adjacent to/connected to/neighbors of a node
Incident to an edge A vertex that is an endpoint of an edge is incident to it
Path A sequence of edges that can be followed from one vertex to another
Cycle A special kind of path that ends at the same vertex where it originally started
Self-test: Edge count vs. vertex count
Suppose that G is an directed graph with N vertices. What's the maximum number of edges that G can have? Assume that a vertex cannot have an edge pointing to itself, and that for each vertex u and vertex v, there is at most one edge (u,v).
N
Incorrect. Draw out a graph with 4 vertices. Can you find more than 4 edges between the nodes?
N2
Incorrect. But it would be correct if a vertex can have an edge to itself.
N*(N-1)
Correct! Every vertex can be connected to every other vertex, of which there are N-1.
N*(N-1)/2
Incorrect. Remember the graph is directed.
Check Solution
Now suppose the same graph G in the above question is an undirected graph. Again assume that no vertex is adjacent to itself, and at most one edge connects any pair of vertices. What's the maximum number of edges that G can have?
half as many edges as in the directed graph
Correct! Remember the edges (u, v) and (v, u) now only count as one edge.
the same number of edges as in the directed graph
Incorrect. Remember the possible edges (u, v) and (v, u) now only count as one edge.
twice as many edges as in the directed graph
Incorrect. Remember the edges (u, v) and (v, u) now only count as one edge.
Check Solution
What's the minimum number of edges that a connected undirected graph with N vertices can have?
N-1
Correct! In fact, an undirected connected graph with N-1 edges is a tree!
N
Incorrect. Think of the small case. How many edges do you need to connect a graph with two nodes?
N2
Incorrect. There aren't this many possible edges in an undirected graph.
N*(N-1)
Incorrect. There aren't this many possible edges in an undirected graph.
N*(N-1)/2
Incorrect. This is all possible edges in the graph! Surely we can do better.
Check Solution