private VertexStats getVertexStatsFromNode(DFTGraph g, DFTNode n) { /* In Degree */ int inDeg = g.InDegree(n); /* Out Degree */ int outDeg = g.OutDegree(n); /* Size of Edge Data */ long sizeSumIncoming; long sizeSumOutgoing; computeStatsDataSize(g, n, out sizeSumIncoming, out sizeSumOutgoing); /* Centrality */ int centralityCount; int totalNodes = g.Vertices.Count(); double centralityRelative; computeStatsCentrality(g, n, totalNodes, out centralityCount, out centralityRelative); /* Closeness Centrality */ return(new VertexStats(n.node_id, n.nameFTR, inDeg, outDeg, sizeSumIncoming, sizeSumOutgoing, centralityCount, centralityRelative, totalNodes, n.nodeFeatures)); }
public static String getNodeNameSanitized(DFTNode n) { String name = n.nameFTR; int index = name.LastIndexOf('/'); if (index > 0) { name = n.nameFTR.Substring(index); } else { name = n.nameFTR.Substring(1); } if (name.Length > 1) { name = name.Replace('>', '_'); name = name.Replace('/', '_'); name = n._nodeType + name; logger.Debug("Generated Name: " + name); return(name); } return(""); }
private static void computeStatsDataSize(DFTGraph g, DFTNode n, out long sizeSumIncoming, out long sizeSumOutgoing) { // compute inData/outData (sum of weights of incoming/outgoing edges) // Console.WriteLine("Node: " + n.nameFTR + ", inDeg: " + g.InDegree(n).ToString()); List <DFTEdge> predEdges = g.getPredecessorEdges(n); List <DFTEdge> succEdges = g.getSuccessorEdges(n); sizeSumIncoming = 0; double sizeSumIncomingRel = 0; sizeSumOutgoing = 0; double sizeSumOutgoingRel = 0; int i = 1; foreach (DFTEdge e in predEdges) { // Console.WriteLine("Pred (" + i + "/" + predEdges.Count + "): " + e._name + ", size: " + e._size + ", Relative: " + e._inSizePercentage + ", (" + e.Source.nameFTR + "->" + e.Target.nameFTR + ")"); sizeSumIncoming += e._size; sizeSumIncomingRel += e._inSizePercentage; i++; } i = 0; foreach (DFTEdge e in succEdges) { // Console.WriteLine("Succ (" + i + "/" + succEdges.Count + "): " + e._name + ", size: " + e._size + ", Relative: " + e._outSizePercentage + ", (" + e.Source.nameFTR + "->" + e.Target.nameFTR + ")"); sizeSumOutgoing += e._size; sizeSumOutgoingRel += e._outSizePercentage; i++; } // Console.WriteLine("Sum Incoming: " + sizeSumIncoming + ", Percentage: " + sizeSumIncomingRel); // Console.WriteLine("Sum Outgoing: " + sizeSumOutgoing + ", Percentage: " + sizeSumIncomingRel); // Console.WriteLine("\n"); }
private void printMetrics(DFTNode n) { Console.WriteLine("Features & Attributes for Node " + n.nameFTR); Console.WriteLine(" Features:"); foreach (DFTNodeFeature f in n.nodeFeatures) { Console.WriteLine(f.name + ", " + f.value); } Console.WriteLine(" Attributes:"); foreach (DFTNodeAttribute a in n.nodeProperties) { Console.WriteLine(a.name + ", " + a.value); } }
private void printMetrics(DFTNode n) { logger.Info("Features & Attributes for Node " + n.nameFTR); logger.Info(" Features:"); foreach (DFTNodeFeature f in n.nodeFeatures) { logger.Info(f.name + ", " + f.value); } logger.Info(" Attributes:"); foreach (DFTNodeAttribute a in n.nodeProperties) { logger.Info(a.name + ", " + a.value); } }
private static void computeStatsCentrality(DFTGraph g, DFTNode n, int totalNodes, out int centralityCount, out double centralityRelative) { // Compute Centrality of Node // Centrality of node n: The number of nodes for which there exists a path p, such that p ends in node n, // in the directed graph, divided by the total number of nodes in the graph centralityCount = 0; foreach (DFTNode node in g.Vertices) { if (g.getConnectingEdges(node, n).Count > 0) { // Console.WriteLine("There exists a path from node " + node.nameFTR + ", to " + n.nameFTR); centralityCount++; } } centralityRelative = ((double)centralityCount / (double)totalNodes) * 100; // Console.WriteLine("Total Centrality Count for node " + n.nameFTR + ": " + centralityCount + ", Relative: " + centralityRelative + " (" + centralityCount + "/" + g.Vertices.Count() + ")"); }
// Construct Model Data from Node and Statistics public static ModelData computeModelDataForNode(DFTNode n, QDFGStatCollection stats) { // The Model Data Object ModelData modelData = null; // Lists holding certain Statistics for each time instance (sampled data) Dictionary <String, List <Double> > timedFeatureList = new Dictionary <String, List <Double> >(); // Obtain the Collection of Vertex Statistics for this Node VertexStatCollection nodeStats = stats.getVertexStatCollectionByID(n.node_id); if (nodeStats != null) // Make sure we were able to obtain the Vertex Statistics for this Node { // Obtain Vertex Stats (of this Node), for all recorded Time Instances Dictionary <int, VertexStats> vertexStatsByTime = nodeStats.getAllStats(); // Iterate over all recorded Time Instances foreach (VertexStats vs in vertexStatsByTime.Values) { // Iterate over all Features within the FeatureSet of this Vertex Stats Object foreach (Feature feature in vs.FeatureSet.Values) { /* * if (feature.Value >= 0) // Filter negative feature Values * {*/ // Get the assigned List for this feature if (timedFeatureList.ContainsKey(feature.Name)) { // Add Feature Value for this time Instance to the List timedFeatureList[feature.Name].Add(feature.Value); } else // No List found for this feature { // Create new List for this Feature timedFeatureList.Add(feature.Name, new List <Double>()); // Add Feature Value for this time Instance to the List timedFeatureList[feature.Name].Add(feature.Value); } //} } } // Create the Model Data Object using the time sampled Data modelData = new ModelData(n.nameFTR, timedFeatureList); } else // nodeStats == null { logger.Fatal("Unable to obtain Vertex Statistics Collection for Node " + n.nameFTR + "; Therefore, no Model Data was produced."); return(null); } // Evaluate Model Data Constraints foreach (KeyValuePair <String, List <Double> > kvp in modelData.TimedFeatureCollection) { if (kvp.Value.Count < Settings.MIN_SAMPLES) { logger.Fatal(modelData.Name + ": Model Data for does not contain enough samples for Statistic <" + kvp.Key + ">. Samples: " + kvp.Value.Count + ", Minimum: " + Settings.MIN_SAMPLES); return(null); } } return(modelData); }
public static DFTNode getPythonNode(DFTGraph g) { DFTNode root = g.getNodeByName("P>python.exe"); return(root); }
public static String getNodeString(DFTNode n) { return("ID <" + n.node_id + ">, Type <" + n._nodeType + ">, Name <" + n.nameFTR + ">"); }
public static DFTGraph getReachableGraphBWD(DFTGraph g, DFTNode n, DFTNodeType type) { return(g.getReachabilityGraphBWD(n, false, type)); }
public static DFTGraph getReachableGraphFWD(DFTGraph g, DFTNode n) { return(g.getReachabilityGraphFWD(n)); }
public static List <DFTEdge> getAllOutgoingEdges(DFTGraph g, DFTNode n) { List <DFTEdge> outEdges = g.OutEdges(n).ToList(); return(outEdges); }
public static List <DFTEdge> getAllIncomingEdges(DFTGraph g, DFTNode n) { List <DFTEdge> inEdges = g.InEdges(n).ToList(); return(inEdges); }
public static DFTGraph getReachableGraphPython(DFTGraph g) { DFTNode root = g.getNodeByName("P>python.exe"); return(g.getReachabilityGraphFWD(root)); }