static void Main(string[] args) { complModelNamedGraph graph = new complModelNamedGraph(); graph.ReuseOptimization = false; LGSPActions actions = new testActions(graph); LGSPGraphProcessingEnvironment procEnv = new LGSPGraphProcessingEnvironment(graph, actions); /* Node_Process p1 = Node_Process.CreateNode(graph); * p1.name = "Siegfried"; * p1.val = 67; * * LGSPNode p2 = graph.AddNode(NodeType_Process.typeVar); * p2.SetAttribute("name", "Dieter"); * if((int) p2.GetAttribute("val") == 0) * p2.SetAttribute("val", 9); * * // INode_Process p1_attr = (INode_Process) p1.attributes; * // p1_attr.name = "Siegfried"; * // p1_attr.val = 67; * * Edge_connection con = (Edge_connection) graph.AddEdge(EdgeType_connection.typeVar, p1, p2); * con.bandwidth = 1000 + p1.val + p1.name.Length;*/ D231_4121 n1 = graph.CreateNodeD231_4121(); n1.a2 = 2; n1.a4 = 4; n1.a5 = 5; n1.b23 = 23; n1.b41 = 41; n1.b42 = 42; n1.d231_4121 = 231; n1["a4"] = 2 * (int)n1["a2"]; // dummy for testing indexer B21 n2 = graph.CreateNodeB21(); n2.a2 = 10002; n2.b21 = 10021; D2211_2222_31 n3 = graph.CreateNodeD2211_2222_31(); n3.a2 = 20002; n3.a3 = 20003; n3.a4 = 20004; n3.b22 = 20022; n3.b41 = 20041; n3.c221 = 20221; n3.c222_411 = 20222; n3.d2211_2222_31 = 22221; graph.CreateEdgeEdge(n1, n2); graph.CreateEdgeEdge(n2, n3); Action_testRule.Instance.Apply(procEnv); using (VCGDumper dumper = new VCGDumper("test.vcg")) GraphDumper.Dump(graph, dumper); }
private void Run() { graph = new StdNamedGraph(); int numNodes = 10; int numEdges = 20; List <Node> nodes = new List <Node>(numNodes); for (int i = 0; i < numNodes; i++) { nodes.Add(Node.CreateNode(graph)); } Random rnd = new Random(4); for (int i = 0; i < numEdges; i++) { Edge.CreateEdge(graph, nodes[rnd.Next(numNodes)], nodes[rnd.Next(numNodes)]); } using (VCGDumper dumper = new VCGDumper("test.vcg")) GraphDumper.Dump(graph, dumper); int visitorID = graph.AllocateVisitedFlag(); DFSWalker dfs = new DFSWalker(graph, PreWalker, PostWalker, visitorID); dfs.DoDFS(nodes[0]); Console.WriteLine("Visited nodes DFS: pre=" + countedNodesPre + " post=" + countedNodesPost); graph.ResetVisitedFlag(visitorID); countedNodesPre = 0; BFSWalker bfs = new BFSWalker(graph, PreWalker, visitorID); bfs.Mode = WalkerMode.Incident; bfs.DoBFS(nodes[0]); Console.WriteLine("Visited nodes BFS: " + countedNodesPre); graph.FreeVisitedFlag(visitorID); }
static void Main(string[] args) { LGSPNamedGraph graph; LGSPActions actions; LGSPBackend.Instance.CreateNamedFromSpec("Mutex.grg", null, 0, out graph, out actions); LGSPGraphProcessingEnvironment procEnv = new LGSPGraphProcessingEnvironment(graph, actions); NodeType processType = graph.GetNodeType("Process"); EdgeType nextType = graph.GetEdgeType("next"); INode p1 = graph.AddNode(processType); INode p2 = graph.AddNode(processType); graph.AddEdge(nextType, p1, p2); graph.AddEdge(nextType, p2, p1); procEnv.ApplyGraphRewriteSequence("newRule[3] && mountRule && requestRule[5] " + "&& (takeRule && releaseRule && giveRule)*"); using (VCGDumper dumper = new VCGDumper("HelloMutex.vcg")) GraphDumper.Dump(graph, dumper); }