Last active
October 16, 2016 04:06
-
-
Save SandeepTuniki/bef0a63a55564fe6649aca25737b87ca to your computer and use it in GitHub Desktop.
Graph Template for c++
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct Node { | |
int id; | |
unordered_map<int, *Node> neighbours; | |
}; | |
struct Edge { | |
Node *source; | |
Node *dest; | |
int weight; | |
}; | |
struct Graph { | |
unordered_map<int, *Node> nodes; | |
unordered_map< pair<int, int>, *Edge > edges; | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Useful when the graph is undirected, and has same edge-lengths across the network. | |
Used for problems like DFS, BFS | |
*/ | |
struct Graph { | |
int n, m; | |
vector<list<int>> neighbours; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment