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()

template<class NodeEntryType>
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 37 of file NodeNetworkHelperFunctions.h.

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

◆ printNetwork()

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

Definition at line 73 of file NodeNetworkHelperFunctions.h.

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