@@ -24,11 +24,53 @@ void Layout911::registerGraphProperties()
2424 GraphManager &gm = GraphManager::getInstance ();
2525 gm.registerProperty (" objectID" , &VertexProperty::objectID);
2626 gm.registerProperty (" name" , &VertexProperty::name);
27+ gm.registerProperty (" type" , &VertexProperty::type);
28+ gm.registerProperty (" y" , &VertexProperty::y);
29+ gm.registerProperty (" x" , &VertexProperty::x);
2730 gm.registerProperty (" servers" , &VertexProperty::servers);
2831 gm.registerProperty (" trunks" , &VertexProperty::trunks);
2932 gm.registerProperty (" segments" , &VertexProperty::segments);
3033}
3134
35+ // Loads Layout911 member variables.
36+ void Layout911::loadParameters ()
37+ {
38+ // Get the number of verticese from the GraphManager
39+ numVertices_ = GraphManager::getInstance ().numVertices ();
40+ }
41+
42+ // Setup the internal structure of the class.
43+ void Layout911::setup ()
44+ {
45+ // Base class allocates memory for: xLoc_, yLoc, dist2_, and dist_
46+ // so we call its method first
47+ Layout::setup ();
48+
49+ // Loop over all vertices and set their x and y locations
50+ GraphManager::VertexIterator vi, vi_end;
51+ GraphManager &gm = GraphManager::getInstance ();
52+ for (boost::tie (vi, vi_end) = gm.vertices (); vi != vi_end; ++vi) {
53+ assert (*vi < numVertices_);
54+ xloc_[*vi] = gm[*vi].x ;
55+ yloc_[*vi] = gm[*vi].y ;
56+ }
57+
58+ // Now we cache the between each pair of vertices distances^2 into a matrix
59+ for (int n = 0 ; n < numVertices_ - 1 ; n++) {
60+ for (int n2 = n + 1 ; n2 < numVertices_; n2++) {
61+ // distance^2 between two points in point-slope form
62+ dist2_ (n, n2) = (xloc_[n] - xloc_[n2]) * (xloc_[n] - xloc_[n2])
63+ + (yloc_[n] - yloc_[n2]) * (yloc_[n] - yloc_[n2]);
64+
65+ // both points are equidistant from each other
66+ dist2_ (n2, n) = dist2_ (n, n2);
67+ }
68+ }
69+
70+ // Finally take the square root to get the distances
71+ dist_ = sqrt (dist2_);
72+ }
73+
3274// Prints out all parameters to logging file.
3375void Layout911::printParameters () const
3476{
0 commit comments