Skip to content

Commit 8e4d9ea

Browse files
Merge pull request #817 from UWB-Biocomputing/SainiGMDevelopment
[ISSUE-648] GraphManager Final Update
2 parents 481e1ce + 4935e44 commit 8e4d9ea

File tree

14 files changed

+268
-265
lines changed

14 files changed

+268
-265
lines changed

Simulator/Connections/NG911/Connections911.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ void Connections911::setup()
2222
AllVertices &vertices = layout.getVertices();
2323

2424
// Get list of edges sorted by target in ascending order from GraphManager
25-
GraphManager &gm = GraphManager::getInstance();
25+
GraphManager<NG911VertexProperties> &gm = GraphManager<NG911VertexProperties>::getInstance();
2626
auto sorted_edge_list = gm.edgesSortByTarget();
2727

2828
// add sorted edges

Simulator/Core/Core.cpp

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -147,11 +147,22 @@ int Core::runSimulation(string executableName, string cmdLineArguments)
147147

148148
// Ask all objects to register their Graph properties
149149
OperationManager::getInstance().executeOperation(Operations::registerGraphProperties);
150-
// Read graph from GraphML file. Uses ParameterManager to get the file name.
151-
// TODO: This method returns false if it fails to read the graph, we ignore it at the
152-
// moment since it currently fails for the Neural Network model because they don't
153-
// yet use GraphML.
154-
GraphManager::getInstance().readGraph();
150+
151+
// Retrieve class attribute from the 'LayoutParams' in the config file
152+
// This value indicate the simulation type (Neural or NG911) for graph manager configuration
153+
// Log fatal error if no simulation type is found and terminate
154+
string configData;
155+
ParameterManager::getInstance().getStringByXpath("//LayoutParams/@class", configData);
156+
157+
if (configData.find("Neur")) {
158+
GraphManager<NeuralVertexProperties>::getInstance().readGraph();
159+
}
160+
if (configData.find("91")) {
161+
GraphManager<NG911VertexProperties>::getInstance().readGraph();
162+
} else {
163+
LOG4CPLUS_FATAL(consoleLogger, "ERROR: Unknown simulation type'");
164+
return -1;
165+
}
155166

156167
// Invoke instantiated simulator objects to load parameters from the configuration file
157168
LOG4CPLUS_TRACE(consoleLogger, "Loading parameters from configuration file");

Simulator/Layouts/Layout.cpp

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -66,17 +66,18 @@ int Layout::getNumVertices() const
6666
/// Load member variables from configuration file. Registered to OperationManager as Operations::op::loadParameters
6767
void Layout::loadParameters()
6868
{
69-
numVertices_ = GraphManager::getInstance().numVertices();
69+
numVertices_ = GraphManager<NeuralVertexProperties>::getInstance().numVertices();
7070
}
7171

7272
void Layout::registerGraphProperties()
7373
{
74-
GraphManager &gm = GraphManager::getInstance();
75-
gm.registerProperty("y", &VertexProperty::y);
76-
gm.registerProperty("x", &VertexProperty::x);
77-
gm.registerProperty("type", &VertexProperty::type);
74+
GraphManager<NeuralVertexProperties> &gm = GraphManager<NeuralVertexProperties>::getInstance();
75+
gm.registerProperty("y", &VertexProperties::y);
76+
gm.registerProperty("x", &VertexProperties::x);
77+
gm.registerProperty("type", &VertexProperties::type);
7878
}
7979

80+
8081
/// Setup the internal structure of the class.
8182
/// Allocate memories to store all layout state, no sequential dependency in this method
8283
void Layout::setup()
@@ -92,8 +93,8 @@ void Layout::setup()
9293
vertexTypeMap_.assign(numVertices_, vertexType::VTYPE_UNDEF);
9394

9495
// Loop over all vertices and set their x and y locations
95-
GraphManager::VertexIterator vi, vi_end;
96-
GraphManager &gm = GraphManager::getInstance();
96+
GraphManager<NeuralVertexProperties>::VertexIterator vi, vi_end;
97+
GraphManager<NeuralVertexProperties> &gm = GraphManager<NeuralVertexProperties>::getInstance();
9798
for (boost::tie(vi, vi_end) = gm.vertices(); vi != vi_end; ++vi) {
9899
assert(*vi < numVertices_);
99100
xloc_[*vi] = gm[*vi].x;
@@ -134,8 +135,8 @@ void Layout::setup()
134135
/// Prints out all parameters to logging file. Registered to OperationManager as Operation::printParameters
135136
void Layout::printParameters() const
136137
{
137-
GraphManager::VertexIterator vi, vi_end;
138-
GraphManager &gm = GraphManager::getInstance();
138+
GraphManager<NeuralVertexProperties>::VertexIterator vi, vi_end;
139+
GraphManager<NeuralVertexProperties> &gm = GraphManager<NeuralVertexProperties>::getInstance();
139140
stringstream output;
140141
output << "\nLAYOUT PARAMETERS" << endl;
141142
output << "\tEndogenously active neuron positions: ";

Simulator/Layouts/NG911/Layout911.cpp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,22 +21,22 @@ void Layout911::registerGraphProperties()
2121
// We are passing a pointer to a data member of the VertexProperty
2222
// so Boost Graph Library can use it for loading the graphML file.
2323
// Look at: https://www.studytonight.com/cpp/pointer-to-members.php
24-
GraphManager &gm = GraphManager::getInstance();
25-
gm.registerProperty("objectID", &VertexProperty::objectID);
26-
gm.registerProperty("name", &VertexProperty::name);
27-
gm.registerProperty("type", &VertexProperty::type);
28-
gm.registerProperty("y", &VertexProperty::y);
29-
gm.registerProperty("x", &VertexProperty::x);
30-
gm.registerProperty("servers", &VertexProperty::servers);
31-
gm.registerProperty("trunks", &VertexProperty::trunks);
32-
gm.registerProperty("segments", &VertexProperty::segments);
24+
GraphManager<NG911VertexProperties> &gm = GraphManager<NG911VertexProperties>::getInstance();
25+
gm.registerProperty("objectID", &NG911VertexProperties::objectID);
26+
gm.registerProperty("name", &NG911VertexProperties::name);
27+
gm.registerProperty("type", &NG911VertexProperties::type);
28+
gm.registerProperty("y", &NG911VertexProperties::y);
29+
gm.registerProperty("x", &NG911VertexProperties::x);
30+
gm.registerProperty("servers", &NG911VertexProperties::servers);
31+
gm.registerProperty("trunks", &NG911VertexProperties::trunks);
32+
gm.registerProperty("segments", &NG911VertexProperties::segments);
3333
}
3434

3535
// Loads Layout911 member variables.
3636
void Layout911::loadParameters()
3737
{
3838
// Get the number of verticese from the GraphManager
39-
numVertices_ = GraphManager::getInstance().numVertices();
39+
numVertices_ = GraphManager<NG911VertexProperties>::getInstance().numVertices();
4040
}
4141

4242
// Setup the internal structure of the class.
@@ -47,8 +47,8 @@ void Layout911::setup()
4747
Layout::setup();
4848

4949
// Loop over all vertices and set their x and y locations
50-
GraphManager::VertexIterator vi, vi_end;
51-
GraphManager &gm = GraphManager::getInstance();
50+
GraphManager<NG911VertexProperties>::VertexIterator vi, vi_end;
51+
GraphManager<NG911VertexProperties> &gm = GraphManager<NG911VertexProperties>::getInstance();
5252
for (boost::tie(vi, vi_end) = gm.vertices(); vi != vi_end; ++vi) {
5353
assert(*vi < numVertices_);
5454
xloc_[*vi] = gm[*vi].x;
@@ -93,8 +93,8 @@ void Layout911::generateVertexTypeMap()
9393
map<string, int> vTypeCount;
9494

9595
// Add all vertices
96-
GraphManager::VertexIterator vi, vi_end;
97-
GraphManager &gm = GraphManager::getInstance();
96+
GraphManager<NG911VertexProperties>::VertexIterator vi, vi_end;
97+
GraphManager<NG911VertexProperties> &gm = GraphManager<NG911VertexProperties>::getInstance();
9898
LOG4CPLUS_DEBUG(fileLogger_, "\nvertices in graph: " << gm.numVertices());
9999
for (boost::tie(vi, vi_end) = gm.vertices(); vi != vi_end; ++vi) {
100100
assert(*vi < numVertices_);

Simulator/Layouts/Neuro/LayoutNeuro.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ void LayoutNeuro::registerGraphProperties()
2828
// We are passing a pointer to a data member of the VertexProperty
2929
// so Boost Graph Library can use it for loading the graphML file.
3030
// Look at: https://www.studytonight.com/cpp/pointer-to-members.php
31-
GraphManager &gm = GraphManager::getInstance();
32-
gm.registerProperty("active", &VertexProperty::active);
31+
GraphManager<NeuralVertexProperties> &gm = GraphManager<NeuralVertexProperties>::getInstance();
32+
gm.registerProperty("active", &NeuralVertexProperties::active);
3333
}
3434

3535
/// Prints out all parameters to logging file.
@@ -52,8 +52,8 @@ void LayoutNeuro::generateVertexTypeMap()
5252
int numExcititoryNeurons;
5353

5454
// Set Neuron Type from GraphML File
55-
GraphManager::VertexIterator vi, vi_end;
56-
GraphManager &gm = GraphManager::getInstance();
55+
GraphManager<NeuralVertexProperties>::VertexIterator vi, vi_end;
56+
GraphManager<NeuralVertexProperties> &gm = GraphManager<NeuralVertexProperties>::getInstance();
5757

5858
for (boost::tie(vi, vi_end) = gm.vertices(); vi != vi_end; ++vi) {
5959
assert(*vi < numVertices_);
@@ -85,8 +85,8 @@ void LayoutNeuro::initStarterMap()
8585
Layout::initStarterMap();
8686

8787
// Set Neuron Activity from GraphML File
88-
GraphManager::VertexIterator vi, vi_end;
89-
GraphManager &gm = GraphManager::getInstance();
88+
GraphManager<NeuralVertexProperties>::VertexIterator vi, vi_end;
89+
GraphManager<NeuralVertexProperties> &gm = GraphManager<NeuralVertexProperties>::getInstance();
9090

9191
for (boost::tie(vi, vi_end) = gm.vertices(); vi != vi_end; ++vi) {
9292
assert(*vi < numVertices_);

Simulator/Utils/CircularBuffer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* @file GraphManager.h
2+
* @file CircularBuffer.h
33
* @author Jardi A. M. Jordan ([email protected])
44
* @date 01-22-2023
55
* Supervised by Dr. Michael Stiber, UW Bothell CSSE Division

Simulator/Utils/Global.h

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -264,30 +264,34 @@ extern const string MATRIX_INIT;
264264
// classes (Layout, Connections, etc) need to do this before we can load the
265265
// graph.
266266

267-
/// Struct for vertex attributes
268-
struct VertexProperty {
269-
// Common Properties:
267+
/// @brief Parent structure to store common properties for all graph vertices
268+
struct VertexProperties {
270269
string type;
271270
double x;
272271
double y;
272+
};
273273

274-
// 911 Properties
274+
/// @brief Derived structure for NG911-specific properties
275+
/// Inherits from VertexProperty and includes attributes specific to 911 networks
276+
struct NG911VertexProperties : public VertexProperties {
275277
string objectID;
276278
string name;
277279
int servers = 0;
278280
int trunks = 0;
279281
string segments;
282+
};
280283

281-
// Neural Properties
284+
/// @brief Derived structure for Neural Network-specific properties
285+
struct NeuralVertexProperties : public VertexProperties {
282286
bool active;
283287
};
284288

285289
/// @brief The structure to hold the edge properties
286-
struct EdgeProperty {
290+
struct EdgeProperties {
287291
// TODO: Edge Properties
288292
};
289293

290294
/// @brief The structure to hold the Graph properties
291-
struct GraphProperty {
295+
struct GraphProperties {
292296
// TODO: Graph Properties
293297
};

Simulator/Utils/GraphManager.cpp

Lines changed: 0 additions & 100 deletions
This file was deleted.

0 commit comments

Comments
 (0)