Monday, May 16, 2016

C++ STL Implementaion, Represeantion and Explantion of Weighted, Unweighted, Directed and Undirected Graph


Explanation, visualization, c++ implementation code for graph adjacency matrix available in the links below,
Links:
Inputting Directed Undirected Weighted Unweighted Graph in C Adjacency Matrix/ Directed Undirected Weighted Unweighted Graph Representation Adjacency Matrix Cheat Sheet/

Explanation:

Here, the first input for the program is vertex or, node count. Next input is the number of edges, then the input based on weight and direction.
The codes here can be combined into a single code to accept various types of graphs.

Sample Input of a Weighted Undirected Graph:

6
7
0 5 5
0 3 9
1 2 4
1 4 3
1 5 1
2 4 2
3 5 7

Graph for the Sample Input:

Complete Visual Representation of the Adjacency List Structure:

Weighted Undirected vector of list implementation:


Sample Input for Unweighted Undirected Graphs:

6
7
0 5
0 3
1 2
1 4
1 5
2 4
3 5

Graph for the Sample Input:

Complete Visual Representation of the Adjacency List Structure:

Unweighted Undirected Graph vector of vector Code:


Sample Input for Unweighted Directed Graphs:

6
7
0 5
0 3
1 2
1 4
1 5
2 4
3 5

Graph for the Sample Input:

Complete Visual Representation of the Adjacency List Structure:

Unweighted Directed Graph vector of vector Code:


Sample Input for Weighted Undirected Graphs:

6
7
0 5 5
0 3 9
1 2 4
1 4 3
1 5 1
2 4 2
3 5 7

Graph for the Sample Input:

Complete Visual Representation of the Adjacency List Structure:

Weighted Undirected Graph vector of vector Code:


Sample Input for Weighted Directed Graphs:

6
7
0 5 5
0 3 9
1 2 4
1 4 3
1 5 1
2 4 2
3 5 7

Graph for the Sample Input:

Complete Visual Representation of the Adjacency List Structure:

Weighted Directed Graph vector of vector Code:


No comments: