Data Structures and Algorithms - #12 (1)
Data Structures and Algorithms - #12 (1)
Implementation of Graph
Structure Through Adjacency
AND ALGORITHMS List Representation
.
.
A, B, C, and D are the vertices of the graph.
2.Edge: The link or path between two vertices is called an edge. It
Graph
connects twoTerminology
or more vertices. The different edges in the above graph
are AB, BC, AD, and DC.
3.Adjacent node: In a graph, if two nodes are connected by an edge
then they are called adjacent nodes or neighbors. In the above graph,
vertices A and B are connected by edge AB. Thus A and B are adjacent
nodes.
4.Degree of the node: The number of edges that are connected to a
particular node is called the degree of the node. In the above graph,
node A has a degree 2.
5.Path: The sequence of nodes that we need to follow when we have
to travel from one vertex to another in a graph is called the path. In our
example graph, if we need to go from node A to C, then the path would
be A->B->C.
.
6.Closed path: If the initial node is the same as a terminal node, then
that path is termed as the closed path.
7.Simple path: A closed path in which all the other nodes are distinct
is called a simple path.
8.Cycle: A path in which there are no repeated edges or vertices and
the first and last vertices are the same is called a cycle. In the above
graph, A->B->C->D->A is a cycle.
9.Connected Graph: A connected graph is the one in which there is a
path between each of the vertices. This means that there is not a single
vertex which is isolated or without a connecting edge. The graph shown
above is a connected graph.
10.Complete Graph: A graph in which each node is connected to
another is called the Complete graph. If N is the total number of nodes
in a graph then the complete graph contains N(N-1)/2 number of edges.
11.Weighted graph: A positive value assigned to each edge
indicating its length (distance between the vertices connected by an
edge) is called weight. The graph containing weighted edges is called a
weighted graph. The weight of an edge e is denoted by w(e) and it
indicates the cost of traversing an edge.
12.Diagraph: A digraph is a graph in which every edge is associated
.
.