119 lines
4.6 KiB
C++
119 lines
4.6 KiB
C++
#include "main.h"
|
|
#include "utility.h"
|
|
|
|
struct Edge {
|
|
bool visted;
|
|
double weight;
|
|
};
|
|
|
|
// using CustomGraph = boost::adjacency_list < boost::vecS, boost::vecS, boost::directedS,
|
|
// Pin,
|
|
// boost::property < boost::edge_index_t, size_t >
|
|
// >;
|
|
|
|
using CustomGraph = boost::adjacency_list < boost::vecS, boost::vecS, boost::directedS,
|
|
boost::property < boost::vertex_index_t, size_t, Pin >,
|
|
boost::property < boost::edge_index_t, size_t, Edge >
|
|
>;
|
|
|
|
using SubGraph = boost::subgraph < Graph >;
|
|
|
|
// https://www.boost.org/doc/libs/1_55_0/libs/graph/doc/write-graphviz.html
|
|
// https://www.boost.org/doc/libs/1_65_0/libs/graph/doc/subgraph.html
|
|
|
|
void test2 ( void ) {
|
|
std::ifstream fileStream;
|
|
|
|
fileStream.open ( "test.csv" );
|
|
|
|
// for testing
|
|
SubGraph W653 ( 16 );
|
|
|
|
std::vector < SubGraph > subgraphs;
|
|
|
|
subgraphs.push_back ( W653.create_subgraph () ); // P1
|
|
subgraphs.push_back ( W653.create_subgraph () );
|
|
subgraphs.push_back ( W653.create_subgraph () );
|
|
subgraphs.push_back ( W653.create_subgraph () );
|
|
subgraphs.push_back ( W653.create_subgraph () );
|
|
subgraphs.push_back ( W653.create_subgraph () );
|
|
subgraphs.push_back ( W653.create_subgraph () ); // P7
|
|
subgraphs.push_back ( W653.create_subgraph () ); // P7
|
|
|
|
get_property ( W653, boost::graph_name ) = "W653";
|
|
get_property ( subgraphs.at ( 1 ), boost::graph_graph_attribute )["label"] = "P1";
|
|
get_property ( subgraphs.at ( 2 ), boost::graph_graph_attribute )["label"] = "P2";
|
|
get_property ( subgraphs.at ( 3 ), boost::graph_graph_attribute )["label"] = "P3";
|
|
get_property ( subgraphs.at ( 4 ), boost::graph_graph_attribute )["label"] = "P4";
|
|
get_property ( subgraphs.at ( 5 ), boost::graph_graph_attribute )["label"] = "P5";
|
|
get_property ( subgraphs.at ( 6 ), boost::graph_graph_attribute )["label"] = "P6";
|
|
get_property ( subgraphs.at ( 7 ), boost::graph_graph_attribute )["label"] = "P7";
|
|
|
|
get_property ( subgraphs.at ( 1 ), boost::graph_name ) = "P1";
|
|
get_property ( subgraphs.at ( 2 ), boost::graph_name ) = "P2";
|
|
get_property ( subgraphs.at ( 3 ), boost::graph_name ) = "P3";
|
|
get_property ( subgraphs.at ( 4 ), boost::graph_name ) = "P4";
|
|
get_property ( subgraphs.at ( 5 ), boost::graph_name ) = "P5";
|
|
get_property ( subgraphs.at ( 6 ), boost::graph_name ) = "P6";
|
|
get_property ( subgraphs.at ( 7 ), boost::graph_name ) = "P7";
|
|
|
|
if ( fileStream.is_open () ) {
|
|
std::string inputLine;
|
|
|
|
// Skip Header
|
|
std::getline ( fileStream, inputLine );
|
|
|
|
while ( std::getline ( fileStream, inputLine ) ) {
|
|
auto values = split ( inputLine, ',' );
|
|
|
|
auto pinAName = values[0];
|
|
auto pinAConnectorType = values[2];
|
|
auto pinBName = values[4];
|
|
auto pinBConnectorType = values[6];
|
|
|
|
Pin pinA ( "W653", pinAName, pinAConnectorType );
|
|
Pin pinB ( "W653", pinBName, pinBConnectorType );
|
|
|
|
Edge e;
|
|
|
|
auto v1 = boost::add_vertex ( subgraphs.at ( 1 ) ); // gives a raw vertex descriptor
|
|
// auto v1 = boost::add_vertex ( 0, subgraphs.at ( 1 ) ); // can still take the int
|
|
|
|
// auto v2 = boost::add_vertex ( pinB, subgraphs.at ( 1 ) );
|
|
|
|
// boost::add_edge ( v1, v2, e, W653 ); // add custom edge.. makes sense
|
|
// boost::add_edge ( v1, v2, subgraphs.at ( 1 ) );
|
|
/*
|
|
qDebug () << "Adding Vertex: " << pinA.mapkeyNumber << " to subgraph " << pinA.legNumber;
|
|
|
|
boost::add_vertex ( pinA, subgraphs.at ( pinA.legNumber ) );
|
|
|
|
qDebug () << "Adding Vertex: " << pinB.mapkeyNumber << " to subgraph " << pinB.legNumber;
|
|
|
|
boost::add_vertex ( pinB, subgraphs.at ( pinB.legNumber ) );
|
|
|
|
boost::add_edge ( pinA, pinB, W653 );
|
|
|
|
if ( pinA.legNumber == pinB.legNumber ) {
|
|
// qDebug () << "Adding Edge: " << pinA.mapkeyNumber << " to " << pinB.mapkeyNumber << " on graph " << pinA.legNumber;
|
|
// boost::add_edge ( pinA.mapkeyNumber, pinB.mapkeyNumber, subgraphs.at ( pinA.legNumber ) );
|
|
|
|
// this causes seg faults... so uhh i guess it doesn't work the way i think it does.
|
|
}
|
|
else {
|
|
// qDebug () << "Adding Edge: " << pinA.mapkeyNumber << " to " << pinB.mapkeyNumber << " on main graph";
|
|
// boost::add_edge ( pinA.mapkeyNumber, pinB.mapkeyNumber, W653 );
|
|
}
|
|
|
|
*/
|
|
}
|
|
}
|
|
|
|
fileStream.close ();
|
|
|
|
std::ofstream dotFile ( "W653.dot" );
|
|
write_graphviz ( dotFile, W653 );
|
|
|
|
qDebug () << "Finished";
|
|
}
|