public void addStats(DFTGraph g, int time) { // iterate over all nodes in the (partial) graph foreach (DFTNode n in g.Vertices) { // if node is not yet recognized, create it with its initial stats if (!vertexStatCollection.ContainsKey(n.node_id)) { vertexStatCollection.Add(n.node_id, new VertexStatCollection(n.node_id, n.nameFTR, n.typeEnum, getVertexStatsFromNode(g, n), time)); nodes.Add(n); } else // if node is already recognized, obtain its stats collection // and update it with a new VertexStats object for this time instance { VertexStatCollection nodeStatCollection = vertexStatCollection[n.node_id]; if (nodeStatCollection.getVertexStatsForTime(time) != null) { logger.Fatal("Time Stats for Node ID " + n.node_id + " (" + n.nameFTR + ") already exist at time " + time); } else { nodeStatCollection.addVertexStatsForTime(time, getVertexStatsFromNode(g, n)); } } } }
public override string ToString() { // Construct Header StringBuilder header = new StringBuilder(); header.Append("nodeID,nodeName,time,"); // List of Feature Names List <String> featureNames = this.vertexStatCollection.Values.First().getAllStats().Values.First().FeatureSet.Keys.ToList(); // Iterate over Names and append to Header for (int i = 0; i < (featureNames.Count - 1); i++) { header.Append(featureNames[i] + ","); } // Append Last Name header.Append(featureNames.Last() + "\r\n"); // Construct Value Set StringBuilder values = new StringBuilder(); foreach (int nodeID in this.vertexStatCollection.Keys) { VertexStatCollection nodeStatCollection = vertexStatCollection[nodeID]; Dictionary <int, VertexStats> stats = nodeStatCollection.getAllStats(); foreach (KeyValuePair <int, VertexStats> statPair in stats) { values.Append(nodeID + "," + statPair.Value.NodeName + "," + statPair.Key + ","); foreach (Feature feature in statPair.Value.FeatureSet.Values) { if (feature != statPair.Value.FeatureSet.Values.Last()) { values.Append(feature.ValueAsString + ","); } else { values.Append(feature.ValueAsString + "\r\n"); } } } } return(header.ToString() + values.ToString()); }