Skip to the content.

Graphs

A graph is a non-linear data structure that can be looked at as a collection of vertices (or nodes) potentially connected by line segments named edges.

some common terminology used when working with Graphs:

  1. Vertex - A vertex, also called a “node”, is a data object that can have zero or more adjacent vertices.
  2. Edge - An edge is a connection between two nodes.
  3. Neighbor - The neighbors of a node are its adjacent nodes, i.e., are connected via an edge.
  4. Degree - The degree of a vertex is the number of edges connected to that vertex.

Directed vs Undirected

  1. Undirected Graphs

For example, in the graph below, Node C is connected to Node A, Node E and Node B. There are no “directions” given to point to specific vertices. The connection is bi-directional.

undirectional

  1. Directed Graphs (Digraph)

directed


Complete vs Connected vs Disconnected

  1. Complete Graphs A complete graph is when all nodes are connected to all other nodes.

  2. Connected A connected graph is graph that has all of vertices/nodes have at least one edge.

  3. Disconnected A disconnected graph is a graph where some vertices may not have edges.


Acyclic vs Cyclic

  1. Acyclic Graph

Here is an example of 3 acyclic graphs:

acycle

  1. Cyclic Graphs

cycle


Graphs