Courses / Computer Science I
Discrete Mathematics

Graphs and Trees

Computer Science I 224 words Free to read

Modeling Connections

A graph is a set of vertices joined by edges, modeling anything from road maps to social networks.

TermDefinitionExample / Rule
DegreeIncident edges on a vertexSum of degrees = 2∣E∣2|E|
PathSequence of connected verticesCan lead to a cycle
ConnectedPath exists between all pairsIsolated nodes disconnect it
DirectedOne-way edges (digraph)Unlike undirected edges

The handshaking lemma states ∑deg⁡(v)=2∣E∣\sum \deg(v) = 2|E| because each edge connects two endpoints. Corollary: odd-degree vertices are always even in number.

Every edge lights two counters at once --- which is the whole lemma

Trees & Pitfalls

A tree is a special graph defined as connected and acyclic. On nn vertices, a tree has exactly n−1n-1 edges and a unique path between any two nodes.

Graph TypeConnected?Acyclic?Edge Count
TreeYesYesn−1n - 1
ForestNoYes<n−1< n - 1
Cycle GraphYesNonn
Common Pitfall: Forgetting that ∑deg⁡(v)\sum \deg(v) equals twice the edges, not ∣E∣|E| alone. A tree must be both connected and acyclic; disconnected acyclic graphs are forests.

Practise this lesson

Try the questions below, free, answers included. The full set, with its interactive scenes, is in the Tryals app.

9practice questions
2interactive scenes

Discrete Mathematics