## root / custompackages / graph-parser / src / main.cpp @ 20756421

History | View | Annotate | Download (2.46 KB)

1 | af008982 | Quynh PX Nguyen | #include <iostream> |
---|---|---|---|

2 | 04a9ef10 | Quynh PX Nguyen | #include "parser.h" |

3 | 6a12e353 | Quynh PX Nguyen | #include "utility.h" |

4 | c6961065 | Quynh PX Nguyen | #include "centrality.h" |

5 | ee0dd796 | Quynh PX Nguyen | #include "bi_connected_components.h" |

6 | cb770240 | Quynh PX Nguyen | #include "graph_manager.h" |

7 | 04a9ef10 | Quynh PX Nguyen | |

8 | |||

9 | ee0dd796 | Quynh PX Nguyen | ```
void handleSimpleGraph() {
``` |

10 | ```
/* I don't understand the output. Why there are 8 vertices?
``` |
||

11 | ```
Simple graph
``` |
||

12 | ```
0
``` |
||

13 | ```
1
``` |
||

14 | ```
2
``` |
||

15 | ```
3
``` |
||

16 | ```
4
``` |
||

17 | ```
5
``` |
||

18 | ```
6
``` |
||

19 | ```
7
``` |
||

20 | ```
8
``` |
||

21 | ```
*/
``` |
||

22 | ```
typedef boost::adjacency_list<> G;
``` |
||

23 | G a; |
||

24 | { |
||

25 | boost::graph_traits<G>::vertex_descriptor v, u, t; |
||

26 | ```
u = vertex(1, a);
``` |
||

27 | ```
v = vertex(8, a);
``` |
||

28 | ```
// t = vertex(5, a);
``` |
||

29 | add_edge(u, v, a); |
||

30 | ```
// add_edge(u, t, a);
``` |
||

31 | } |
||

32 | |||

33 | ```
std::set<typename boost::graph_traits<G>::vertex_descriptor> av;
``` |
||

34 | ```
cout << "Simple graph" << endl;
``` |
||

35 | BGL_FORALL_VERTICES_T(v, a, G) { |
||

36 | cout << v << endl; |
||

37 | } |
||

38 | } |
||

39 | 04a9ef10 | Quynh PX Nguyen | void handleSimpleInput(string filePath) { |

40 | ```
// Read the input.edges
``` |
||

41 | Graph g; |
||

42 | 6a12e353 | Quynh PX Nguyen | readEdgeFile(filePath, g); |

43 | |||

44 | 04a9ef10 | Quynh PX Nguyen | ```
cout << "Finish creating graph" << endl;
``` |

45 | |||

46 | ```
simpleBetweennessCentrality(g, "edge_list");
``` |
||

47 | af008982 | Quynh PX Nguyen | } |

48 | |||

49 | void handleJsonInput(string filePath) { |
||

50 | Graph g; |
||

51 | readJson(filePath, g); |
||

52 | 20756421 | Quynh PX Nguyen | ```
outops::operator<<(cout, g);
``` |

53 | af008982 | Quynh PX Nguyen | |

54 | ```
// Applying the betweenness centrality
``` |
||

55 | 04a9ef10 | Quynh PX Nguyen | ```
simpleBetweennessCentrality(g, "json_olsr");
``` |

56 | |||

57 | ```
cout << "Done with Betweenness Centrality" << endl;
``` |
||

58 | } |
||

59 | |||

60 | void handleComplexJsonInput(string filePath) { |
||

61 | Graph g; |
||

62 | readComplexJson(filePath, g); |
||

63 | 20756421 | Quynh PX Nguyen | ```
outops::operator<<(cout, g);
``` |

64 | 04a9ef10 | Quynh PX Nguyen | |

65 | ```
// Applying the betweenness centrality
``` |
||

66 | ```
simpleBetweennessCentrality(g, "json_topology");
``` |
||

67 | af008982 | Quynh PX Nguyen | |

68 | ```
cout << "Done with Betweenness Centrality" << endl;
``` |
||

69 | } |
||

70 | |||

71 | ee0dd796 | Quynh PX Nguyen | void testHeuristic(string filePath) { |

72 | cb770240 | Quynh PX Nguyen | GraphManager gm; |

73 | readEdgeFileGraphManager(filePath, gm); |
||

74 | BiConnectedComponents bcc(gm); |
||

75 | ee0dd796 | Quynh PX Nguyen | ```
cout << "DONE" << endl;
``` |

76 | cb770240 | Quynh PX Nguyen | } |

77 | ee0dd796 | Quynh PX Nguyen | |

78 | cb770240 | Quynh PX Nguyen | void testGraphManager(string filePath) { |

79 | GraphManager gm; |
||

80 | readEdgeFileGraphManager(filePath, gm); |
||

81 | cout << gm; |
||

82 | |||

83 | gm.ResetVerticesAndEdgesIndexMap(); |
||

84 | gm.print_v_index_map(); |
||

85 | 04a9ef10 | Quynh PX Nguyen | |

86 | ee0dd796 | Quynh PX Nguyen | } |

87 | af008982 | Quynh PX Nguyen | |

88 | ee0dd796 | Quynh PX Nguyen | int main(int, char *[]) { |

89 | ```
// string edgeFilePath = "../input/ninux_30_1.edges";
``` |
||

90 | ```
// testHeuristic(edgeFilePath);
``` |
||

91 | ```
// handleSimpleInput(edgeFilePath);
``` |
||

92 | ```
//
``` |
||

93 | ```
// string jsonFilePath = "../input/olsr-netjson.json";
``` |
||

94 | ```
// handleJsonInput(jsonFilePath);
``` |
||

95 | ```
//
``` |
||

96 | ```
// string complexJsonFilePath = "../input/jsoninfo_topo.json";
``` |
||

97 | ```
// handleComplexJsonInput(complexJsonFilePath);
``` |
||

98 | 04a9ef10 | Quynh PX Nguyen | |

99 | cb770240 | Quynh PX Nguyen | ```
// string simpleGraphFilePath = "../input/simple.edges";
``` |

100 | ```
// testGraphManager(simpleGraphFilePath);
``` |
||

101 | 04a9ef10 | Quynh PX Nguyen | |

102 | ee0dd796 | Quynh PX Nguyen | string simpleGraphFilePath = "../input/simple.edges"; |

103 | testHeuristic(simpleGraphFilePath); |
||

104 | cb770240 | Quynh PX Nguyen | |

105 | af008982 | Quynh PX Nguyen | return 0; |

106 | } |