This repository was archived by the owner on May 27, 2019. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -53,5 +53,18 @@ void DirectedGraph::loadRawDataToMatrix(std::vector<int> rawData) {
5353}
5454
5555void DirectedGraph::loadRawDataToList (std::vector<int > rawData) {
56+ adjacencyList.clear ();
57+ int i = 0 ;
58+
59+ int numberOfEdges = rawData[i++];
60+
61+ adjacencyList.resize (rawData[i++]);
62+
63+ for (int j = 0 ; j < numberOfEdges; j++) {
64+ int edgeBeginning = rawData[i++];
65+ int edgeEnd = rawData[i++];
66+ int edgeValue = rawData[i++];
5667
68+ adjacencyList[edgeBeginning].push_front ({edgeEnd, edgeValue});
69+ }
5770}
Original file line number Diff line number Diff line change @@ -53,5 +53,23 @@ void UndirectedGraph::loadRawDataToMatrix(vector<int> rawData) {
5353}
5454
5555void UndirectedGraph::loadRawDataToList (std::vector<int > rawData) {
56+ adjacencyList.clear ();
57+ int i = 0 ;
58+
59+ int numberOfEdges = rawData[i++];
60+
61+ adjacencyList.resize (rawData[i++]);
62+
63+ for (int j = 0 ; j < numberOfEdges; j++) {
64+ int edgeBeginning = rawData[i++];
65+ int edgeEnd = rawData[i++];
66+ int edgeValue = rawData[i++];
67+
68+ adjacencyList[edgeBeginning].push_front ({edgeEnd, edgeValue});
5669
70+ if (edgeBeginning == edgeEnd)
71+ continue ;
72+
73+ adjacencyList[edgeEnd].push_front ({edgeBeginning, edgeValue});
74+ }
5775}
You can’t perform that action at this time.
0 commit comments