Belle II Software development
Belle2::DNN Namespace Reference

namespace for DirectedNodeNetwork-related stuff More...

Functions

template<class NodeEntryType >
void printCANetwork (DirectedNodeNetwork< NodeEntryType, CACell > &network, const std::string &fName)
 TODO.
 
template<class NodeEntryType , class AnyMetaInfo >
void printNetwork (DirectedNodeNetwork< NodeEntryType, AnyMetaInfo > &network, const std::string &fName)
 overloaded print-version for typical activeSector-networks without CACell-stuff
 

Detailed Description

namespace for DirectedNodeNetwork-related stuff

Function Documentation

◆ printCANetwork()

void printCANetwork ( DirectedNodeNetwork< NodeEntryType, CACell > &  network,
const std::string &  fName 
)

TODO.

  • code isSeed and getState to colors for fill and for border function for printing networks with CACells:

takes network and prints it to given fileName.

prerequisite for NodeEntryType:

  • std::string getName()

Definition at line 38 of file NodeNetworkHelperFunctions.h.

39 {
40 std::string fullOut = "digraph G {\n";
41 fullOut +=
42 "ranksep=\"0.2\" edge[labelfontsize=\"8\" fontsize=\"8\" arrowsize=\"0.9\"] nodesep=\"0.2\" node[shape=\"box\" width=\"0\" height=\"0\" fontsize=\"10\"]\n";
43 // write vertices:
44 for (auto* node : network) {
45 fullOut += "\"" + node->getEntry().getName() + "\"" +
46 " [label=\"" +
47 node->getEntry().getName() +
48 " State,Seed: " +
49 std::to_string(node->getMetaInfo().getState()) +
50 "," +
51 std::to_string(node->getMetaInfo().isSeed()) +
52 "\"];\n";
53 }
54 // write edges:
55 for (auto* node : network) {
56 for (auto* innerNode : node->getInnerNodes()) {
57 auto innerEntry = innerNode->getEntry();
58 std::string arrowStyle = (node->getMetaInfo().getState() == (innerNode->getMetaInfo().getState() + 1)) ? "" : " [style=dotted]";
59 fullOut += "\"" + node->getEntry().getName() + "\" -> \"" + innerEntry.getName() + "\"" + arrowStyle + ";\n";
60 }
61 }
62 fullOut += "labelloc=\"t\";\nlabel=\"" + fName + "\";\n";
63 fullOut += "}\n";
64
65 std::ofstream ofs;
66 ofs.open(fName + ".gv", std::ofstream::out | std::ofstream::trunc);
67 ofs << fullOut;
68 ofs.close();
69 };

◆ printNetwork()

void printNetwork ( DirectedNodeNetwork< NodeEntryType, AnyMetaInfo > &  network,
const std::string &  fName 
)

overloaded print-version for typical activeSector-networks without CACell-stuff

Definition at line 75 of file NodeNetworkHelperFunctions.h.

76 {
77 std::string fullOut = "digraph G {\n";
78 fullOut +=
79 "ranksep=\"0.2\" edge[labelfontsize=\"8\" fontsize=\"8\" arrowsize=\"0.9\"] nodesep=\"0.2\" node[shape=\"box\" width=\"0\" height=\"0\" fontsize=\"10\"]\n";
80
81 // write vertices:
82 for (auto* node : network) {
83 fullOut += "\"" + node->getEntry().getName() + "\"" +
84 " [label=\"" +
85 node->getEntry().getName() +
86 "\"];\n";
87 }
88 // write edges:
89 for (auto* node : network) {
90 for (auto* innerNode : node->getInnerNodes()) {
91 auto innerEntry = innerNode->getEntry();
92 std::string arrowStyle = "";
93 fullOut += "\"" + node->getEntry().getName() + "\" -> \"" + innerEntry.getName() + "\"" + arrowStyle + ";\n";
94 }
95 }
96 fullOut += "labelloc=\"t\";\nlabel=\"" + fName + "\";\n";
97 fullOut += "}\n";
98
99 std::ofstream ofs;
100 ofs.open(fName + ".gv", std::ofstream::out | std::ofstream::trunc);
101 ofs << fullOut;
102 ofs.close();
103 };