-
Notifications
You must be signed in to change notification settings - Fork 0
/
graphTh.cpp
82 lines (72 loc) · 1.57 KB
/
graphTh.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#include <bits/stdc++.h>
using namespace std;
int main()
{
// we use graph to store relational data set
// difference between tree and graph
// every tree is graph but not every graph is tree
/*
tree is a acyclic ds graph can be acyclic or cyclic
*/
// node, edge
// bidirectional direction
// non weighted edge, weighted edge
// 4 types of graph
//1. bi->nw
//2. d->nw
//3. bi->w
//4. d->w
// complete graph -> every node is connected to every node (e = (n(n-1))/2)
// number of edges
// 1. dense graph (if the val of edge is close to complete graph edge)
// 2. sporse graph
// Adjacency Matrix
// the number represent the connection from one node to another
// it's a non weighted graph
/*
a b c d e
a 0 0 1 0 0
b 0 0 0 0 0
c 0 1 0
d 0
e 1
*/
// it's a weighted graph
/*
a b c d e
a 0 6 5 3 0
b 6 0 2 0 0
c 0 1 0
d 0
e 1
*/
//Adjacency List
// it's an array of list
// creating graph with list is better to optimize some algorithom
// non weighted graph
/*
a b c
b
c d b
d a e
e c
*/
// weighted graph
// list pair<char,int>
/*
a b,6 c,5
b a,6 c,2
c b,2 a,5 e,1
d
e
*/
// dfs bfs
// spaning tree
// we will create a tree without any loop
/*
spaning tree is a tree genarated from a graph which cover all the nodes
and create a asyclic tree
*/
// bfs spaning tree
return 0;
}