-
Notifications
You must be signed in to change notification settings - Fork 0
/
graphwriter.cpp
60 lines (55 loc) · 2.15 KB
/
graphwriter.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#include "graphwriter.h"
GraphWriter::GraphWriter(QString output_filename, InfoParser *info)
: SpineMLWriter(output_filename)
{
out.setDevice(output_file);
this->info = info;
}
void GraphWriter::writeDocumentStart()
{
out << "// Neato graph produced by SpineML splitter" << endl;
out << "// Example neato usage: neato -Tpng graph.dot -o graph.png" << endl << endl;
out << "graph G {" << endl;
out << "\toverlap=scale" << endl;
out << "\tsplines=true" << endl;
if (info->getSplitterMode() == SPLITMODE_PROJ_DEF_AT_SRC)
out << "\tdir=forward" << endl;
else
out << "\tedge [dir=back]" << endl;
}
void GraphWriter::writeDocuemntEnd()
{
out << "}" << endl;
}
void GraphWriter::writePopulation(Population *sub_population, Population *)
{
QSet <QString> connections;
QString sub_pop_name_safe = sub_population->neuron->name;
sub_pop_name_safe = sub_pop_name_safe.replace(" ", "_");
//interrupts
if ((sub_population->projections.values().size() > 0) || (sub_population->neuron->inputs.values().size() > 0))
//synapse nodes
for (int p=0; p<sub_population->projections.values().size(); p++){
Projection * sub_proj = sub_population->projections.values()[p];
QString sub_proj_pop_name_safe = sub_proj->proj_population;
sub_proj_pop_name_safe = sub_proj_pop_name_safe.replace(" ", "_");
QString proj = "\t%1 -- %2";
proj = proj.arg(sub_pop_name_safe).arg(sub_proj_pop_name_safe);
connections.insert(proj);
}
//input nodes to neuron
for (int i=0; i<sub_population->neuron->inputs.values().size(); i++){
Input * sub_input = sub_population->neuron->inputs.values()[i];
QString sub_inp_pop_name_safe = sub_input->src;
sub_inp_pop_name_safe = sub_inp_pop_name_safe.replace(" ", "_");
QString input = "\t%1 -- %2";
input = input.arg(sub_pop_name_safe).arg(sub_inp_pop_name_safe);
connections.insert(input);
}
//TODO INPUT NODES TO PSP
//output unique connections
for (int i=0; i<connections.values().size(); i++){
QString conn = connections.values()[i];
out << conn << endl;
}
}