-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
moved all graph stuff to a class and began fine tuning reading function
- Loading branch information
Showing
6 changed files
with
106 additions
and
49 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// | ||
// Created by Daniel Ryan on 4/5/22. | ||
// | ||
|
||
#include "Graph_helper.h" | ||
|
||
|
||
void Graph_helper::print_graph() { | ||
boost::print_graph(graph, get(&VertexProperty::name, graph)); | ||
} | ||
|
||
void Graph_helper::print_edges() { | ||
auto epair = boost::edges(graph); | ||
for(auto iter = epair.first; iter != epair.second; iter++) | ||
std::cout << "edge " << *iter << std::endl; | ||
} | ||
|
||
void Graph_helper::print_vertices() { | ||
auto vpair = boost::vertices(graph); | ||
for(auto iter = vpair.first; iter != vpair.second; iter++) | ||
std::cout << "vertex " << *iter << std::endl; | ||
} | ||
|
||
void Graph_helper::read_graphml(const char* file) { | ||
std::ifstream is; | ||
is.open(file); | ||
if(!is.is_open()) { | ||
std::cout << "[ERROR]: could not open Graphml file" << std::endl; | ||
return; | ||
} | ||
|
||
try { | ||
boost::dynamic_properties dp(boost::ignore_other_properties); | ||
dp.property("name", boost::get(&VertexProperty::name, graph)); | ||
dp.property("community", boost::get(&VertexProperty::community, graph)); | ||
boost::read_graphml(is, graph, dp); | ||
}catch(std::exception& e) { | ||
std::cout << e.what() << std::endl; | ||
return; | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// | ||
// Created by Daniel Ryan on 4/5/22. | ||
// | ||
|
||
#ifndef INC_22S_PA03_GRAPH_HELPER_H | ||
#define INC_22S_PA03_GRAPH_HELPER_H | ||
|
||
#include <iostream> | ||
#include <utility> | ||
#include <algorithm> | ||
#include <boost/graph/graph_traits.hpp> | ||
#include <boost/graph/adjacency_list.hpp> | ||
#include <boost/graph/graph_utility.hpp> | ||
#include <boost/graph/graphml.hpp> | ||
#include <boost/property_map/dynamic_property_map.hpp> | ||
#include <boost/property_map/property_map.hpp> | ||
#include <typeinfo> | ||
#include <cxxabi.h> | ||
#include <fstream> | ||
|
||
struct GraphData { int community; }; | ||
struct VertexProperty { | ||
std::string name; | ||
int community; | ||
}; | ||
struct EdgeProperty { std::string Name; }; | ||
|
||
using Graph = boost::adjacency_list<boost::setS, boost::vecS, boost::undirectedS, VertexProperty, EdgeProperty>; | ||
|
||
class Graph_helper { | ||
private: | ||
Graph graph; | ||
|
||
public: | ||
void print_graph(); | ||
void print_edges(); | ||
void print_vertices(); | ||
|
||
void read_graphml(const char*); | ||
|
||
|
||
}; | ||
|
||
#endif //INC_22S_PA03_GRAPH_HELPER_H |
This file contains 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