Skip to content

Latest commit

 

History

History
74 lines (47 loc) · 3.03 KB

02.introToGraph.md

File metadata and controls

74 lines (47 loc) · 3.03 KB
- text in red
+ text in green
! text in orange
# text in gray
@@ text in purple (and bold)@@

Introduction

Types of graph

  • Two types of graph:
    • Undirected graph
    • Directed graph

Screenshot from 2021-08-27 13-39-30

Degree, Indegree and Outdegree

  • Degree, Indegree and Outdegree
    • In Undirected graph

      • No of nodes connected with the vertex is called degree in case of undirected graph.
    • In Directed graph

      • No of incoming nodes in undirected graph is called indegree.
      • No of Outgoing nodes in undirected graph is called outdegree.
+Total degree of all the nodes in an undirected graph will be equal to the 2 multiplied by total no. of edges, i.e(2xE)

as we know that every edge is contibuting for 2 degrees.

Screenshot from 2021-08-27 13-42-52

Path

  • Path in a graph
    • In an undirected graph: Path is the sequence of nodes or vertex such that none of the nodes are repeating or visited twice in the path
    • In directed graph: If there is an edge between 1 to 5 then you can go from 1 to 5 but you can't go from 5 to 1.

Cyclic and Acylic

  • Undirected cyclic graph: If there is a cycle in an undirected graph then it is called undirected cyclic graph.

Screenshot from 2021-08-27 14-28-55

  • Undirected Acylic graph: If there is no cycle in an undirected graph then it is called undirected acylic graph.

Screenshot from 2021-08-27 14-30-41

  • Directed cyclic graph: If there is a cycle in a directed graph then that is called directed cyclic graph.

Screenshot from 2021-08-27 14-31-12

  • Directed Acylic graph: If there is no cycle in a directed graph then it is called directed acylic graph, this is commonly known as DAG(will be used many times).

Screenshot from 2021-08-27 14-30-52

Now the last kind of graph is the weighted graph, all of the above types will be there in the weighted graph also

Weighted graph

  • Undirected weighted graph
    • Undirected weighted cyclic graph
    • Undirected weighted acylic graph
  • Directed weighted graph
    • Directed weighted cyclic graph
    • Directed weighted acylic graph

Important point: If the weights are not given i.e if the graph is unweighted and you are solving a problem where weight is necessary and you need the weight to perform certain operations, consider the weight of each edge to be the unit weight i.e 1.