Graphs
A Graph is a non-linear data structure that
consists of vertices (nodes) and edges.
A vertex, also called a node, is a point or an
object in the Graph, and an edge is used to
connect two vertices with each other.
Graphs are used to represent and solve problems
where the data consists of objects and
relationships between them.
Graph Properties
A weighted Graph is a Graph where the edges have
values. The weight value of an edge can represent
things like distance, capacity, time, or
probability.
A connected Graph is when all the vertices are
connected through edges somehow. A Graph that is
not connected, is a Graph with isolated (disjoint)
subgraphs, or single isolated vertices.
A directed Graph, also known as a digraph, is when
the edges between the vertex pairs have a
direction. The direction of an edge can represent
things like hierarchy or flow.
A loop, also called a self-loop, is an edge that
begins and ends on the same vertex. A loop is a
cycle that only consists of one edge.
Graph Representations
- Adjacency Matrix Graph Representation
- Adjacency List Graph Representation