Answers for "graph representation"


graph representation

	- adjacency matrix (linear representation) 
			Pro: esay implement, removing edge=O(1), queries of vertex or edge is O(1), 
			Cons: Consume space O(V^2), adding a vertex is O(V^2) ;
	- adjacency list 
		-ArrayList (or Array of LinkedList) 
			Pro: save space: O(|V|+|E|), worst case O(V^2)
			Cons: queries are not efficient O(V);
		-LinkedList - a pointer from one vertex to second
		-HashMap collection. K,V . (adjancency list in HashMap)
			private HashMap<Integer, Node> nodeLookup = new HashMap<Integer, Node>();
	- Incidence Matrix
	- Incidence List
Posted by: Guest on October-13-2021

Code answers related to "graph representation"

Browse Popular Code Answers by Language