3 import matplotlib.pyplot
as plt
7 Purpose: This is a simple graphing tool to find the relationship between number of nodes
8 and number of constraints over time.
10 To use: add the following code to publishGraph and disable the optimizer printouts
12 std::map<karto::Name, std::vector<karto::Vertex<karto::LocalizedRangeScan>*> > vertices = mapper_->GetGraph()->GetVertices();
13 std::vector<karto::Vertex<karto::LocalizedRangeScan>*>::const_iterator it;
14 std::map<int, int> vertex_ctr;
15 for (it = vertices[mapper_->GetMapperSensorManager()->GetSensorNames()[0]].begin(); it != vertices[mapper_->GetMapperSensorManager()->GetSensorNames()[0]].end(); ++it)
17 int num = (*it)->GetEdges().size();
18 if (vertex_ctr.find(num) == vertex_ctr.end())
25 std::cout << "UpdateMap: Vertex count: " << std::endl;
26 std::map<int, int>::const_iterator it2;
27 for (it2 = vertex_ctr.begin(); it2 != vertex_ctr.end(); ++it2)
29 std::cout << it2->first << " constraints are in " << it2->second << " vertexes" << std::endl;
31 std::cout << std::endl;
35 with open(filename)
as fp:
50 if "UpdateMap: Vertex count:" in line:
51 measurements.append(measurement)
53 measurement.append(line)
54 return measurements[1:]
59 for measurement
in measurements:
62 nums = [r
for r
in txt
if r.isdigit()]
65 measurement_out.append(nums)
66 measurements_out.append(measurement_out)
68 return measurements_out
90 local_keys.append(pt[0])
91 dat[pt[0]].append(int(pt[1]))
93 if k
not in local_keys:
100 summ = summ + int(pt[1])
101 total_nodes.append(summ)
104 plt.plot( [10*i
for i
in range(0, len(dat[k]))], dat[k], marker=
'o', color=[random.random(),random.random(),random.random()], linewidth=2, label=k+
' Constraints')
106 plt.plot( [10*i
for i
in range(0, len(dat[k]))], total_nodes, marker=
'o', color=[random.random(),random.random(),random.random()], linewidth=2, label=
'Total Num. Nodes')
108 plt.xlabel(
"time (s)")
109 plt.ylabel(
"Node count")
113 if __name__ ==
"__main__":
114 filename = sys.argv[1]
115 print (
"reading file: " + filename)