private void CreateProliferation(DGraph graph, DCluster proliferation) { var inNode = graph.AddNode("Proliferation_in"); inNode.DrawingNode.Attr.Shape = MsaglShape.Circle; inNode.DrawingNode.Attr.FillColor = MsaglColor.Red; graph.AddNodeToCluster(proliferation, inNode); var splitter = graph.AddNode("Proliferation_Splitter"); splitter.DrawingNode.Attr.Shape = MsaglShape.Circle; splitter.DrawingNode.Attr.FillColor = MsaglColor.Blue; graph.AddNodeToCluster(proliferation, splitter); var mitosis = graph.AddCluster(proliferation, "Mitosis"); Clustering_ApplyNodeAttributes(mitosis); CreateMitosis(graph, mitosis); var meiosis = graph.AddCluster(proliferation, "Meiosis"); Clustering_ApplyNodeAttributes(meiosis); CreateMeiosis(graph, meiosis); Clustering_Cell_AddEdge(graph, inNode, mitosis, null); Clustering_Cell_AddEdge(graph, mitosis, splitter, "Early Meiosis"); Clustering_Cell_AddEdge(graph, splitter, graph.NodeMap["G0"], null); Clustering_Cell_AddEdge(graph, splitter, graph.NodeMap["Inter"], null);//*/ }
private void CreateInitialGraph(DGraph dgraph) { var nodeA0 = dgraph.AddNode("A0"); nodeA0.Node.Attr.Shape = Microsoft.Msagl.Drawing.Shape.Box; nodeA0.Node.Attr.XRadius = 5.0; nodeA0.Node.Attr.YRadius = 5.0; nodeA0.Node.Attr.FillColor = Microsoft.Msagl.Drawing.Color.Green; nodeA0.Label = new DTextLabel(nodeA0, new Microsoft.Msagl.Drawing.Label()) { Text = "Node A0", Margin = new Thickness(5.0, 2.0, 5.0, 2.0) }; dgraph.AddNode("A1"); dgraph.AddNode("A2").Node.Attr.FillColor = Microsoft.Msagl.Drawing.Color.Blue; var nodeA3 = dgraph.AddNode("A3"); var edgeA0A1 = dgraph.AddEdgeBetweenNodes(dgraph.NodeMap["A0"], dgraph.NodeMap["A1"]); dgraph.AddEdgeBetweenNodes(dgraph.NodeMap["A0"], dgraph.NodeMap["A2"]); dgraph.AddEdgeBetweenNodes(dgraph.NodeMap["A2"], dgraph.NodeMap["A1"]); dgraph.AddEdgeBetweenNodes(dgraph.NodeMap["A0"], dgraph.NodeMap["A3"]); nodeA3.Label = new DTextLabel(nodeA3, new Microsoft.Msagl.Drawing.Label()) { Text = "Node A3" }; edgeA0A1.Label = new DTextLabel(edgeA0A1, new Microsoft.Msagl.Drawing.Label()) { Text = "Edge A0->A1" }; dgraph.Graph.Attr.LayerDirection = Microsoft.Msagl.Drawing.LayerDirection.RL; }
private void CreateGamete(DGraph graph, DCluster gamete) { var inNode = graph.AddNode("Gamete_in"); inNode.DrawingNode.Attr.Shape = MsaglShape.Circle; inNode.DrawingNode.Attr.FillColor = MsaglColor.Red; graph.AddNodeToCluster(gamete, inNode); var splitter = graph.AddNode("Gamete_Splitter"); splitter.DrawingNode.Attr.Shape = MsaglShape.Circle; splitter.DrawingNode.Attr.FillColor = MsaglColor.Blue; graph.AddNodeToCluster(gamete, splitter); var sperm = Clustering_Cell_AddNode(graph, gamete, "Sperm", "Sperm"); var oocyte = Clustering_Cell_AddNode(graph, gamete, "Oocyte", "Oocyte"); var matureOocyte = Clustering_Cell_AddNode(graph, gamete, "MatureOocyte", "Mature\nOocyte"); var zygote = Clustering_Cell_AddNode(graph, gamete, "Zygote", "Zygote"); Clustering_Cell_AddEdge(graph, inNode, splitter, null); Clustering_Cell_AddEdge(graph, splitter, sperm, "Sperm_Effector_Act"); Clustering_Cell_AddEdge(graph, splitter, oocyte, "Oocyte_Effector_Act"); Clustering_Cell_AddEdge(graph, oocyte, matureOocyte, "Maturation"); Clustering_Cell_AddEdge(graph, matureOocyte, zygote, "Fertilization");//*/ }
private void CreateInitialGraph(DGraph dgraph) { var nodeA0 = dgraph.AddNode("A0"); dgraph.AddNode("A1"); dgraph.AddNode("A2"); var nodeA3 = dgraph.AddNode("A3"); nodeA0.Node.Attr.Shape = Microsoft.Msagl.Drawing.Shape.Box; nodeA0.Node.Attr.XRadius = 5.0; nodeA0.Node.Attr.YRadius = 5.0; var edgeA0A1 = dgraph.AddEdgeBetweenNodes(dgraph.NodeMap["A0"], dgraph.NodeMap["A1"]); dgraph.AddEdgeBetweenNodes(dgraph.NodeMap["A0"], dgraph.NodeMap["A2"]); dgraph.AddEdgeBetweenNodes(dgraph.NodeMap["A2"], dgraph.NodeMap["A1"]); dgraph.AddEdgeBetweenNodes(dgraph.NodeMap["A0"], dgraph.NodeMap["A3"]); nodeA0.Label = new DTextLabel(nodeA0, new Microsoft.Msagl.Drawing.Label()) { Text = "Node A0" }; nodeA3.Label = new DTextLabel(nodeA3, new Microsoft.Msagl.Drawing.Label()) { Text = "Node A3" }; edgeA0A1.Label = new DTextLabel(edgeA0A1, new Microsoft.Msagl.Drawing.Label()) { Text = "Edge A0->A1" }; }
static void ConnectTest() { Console.Write("This test displays a connection table for a directed graph\n\n"); // create the graph DGraph tree1 = new DGraph(); //add nodes tree1.AddNode('A'); tree1.AddNode('C'); tree1.AddNode('T'); tree1.AddNode('Z'); tree1.AddNode('X'); tree1.AddNode('K'); tree1.AddNode('Q'); tree1.AddNode('J'); tree1.AddNode('M'); tree1.AddNode('U'); // add some edges tree1.AddEdge('A', 'C'); tree1.AddEdge('A', 'T'); tree1.AddEdge('A', 'Z'); tree1.AddEdge('X', 'C'); tree1.AddEdge('C', 'X'); tree1.AddEdge('C', 'K'); tree1.AddEdge('T', 'Q'); tree1.AddEdge('K', 'Q'); tree1.AddEdge('Q', 'J'); tree1.AddEdge('J', 'M'); tree1.AddEdge('Z', 'X'); tree1.AddEdge('U', 'M'); tree1.AddEdge('K', 'X'); // uncomment the next line to see your node list, edge list, and edge matrix Debug1(tree1); Console.Write("The breadth first min tree from A should be: \n"); Console.Write(" A-Z A-Z A-T A-C Z-X T-Q C-K Q-J J-M with U unreachable\n"); Console.Write(" is: " + tree1.BreadthFirst('A') + "\n\n"); Console.Write("Note that the order of nodes in your output might differ\n"); Console.Write("what is important which nodes are reached from each start\n"); Console.Write("The graph connect table should be: \n"); Console.Write("A: Z X C K Q J M T \n"); Console.Write("C: K X Q J M\n"); Console.Write("T: Q J M\n"); Console.Write("Z: X C K Q J M\n"); Console.Write("X: C K Q J M\n"); Console.Write("K: X C Q J M\n"); Console.Write("Q: J M\n"); Console.Write("J: M\n"); Console.Write("M:\n"); Console.Write("U: M \n\n"); Console.Write("The graph connect table is: \n"); Console.Write(tree1.ConnectTable() + "\n\n"); Console.Write("End of testing connection table\n\n"); }
static void Main(string[] args) { DGraph graph = new DGraph(); NodeD testV1 = new NodeD("Sea"); NodeD testV2 = new NodeD("Chi"); NodeD testV3 = new NodeD("SF"); graph.AddNode(testV1); graph.AddNode(testV2); //graph.AddNode(testV3); graph.AddEdge(testV1, testV2, 150); //graph.AddEdge(testV2, testV3, 250); string[] travel = new string[] { "Sea", "Chi" }; //List<Node> nodes = graph.GetNodes(); //foreach (var item in nodes) //{ // Console.WriteLine(item.Value.ToString()); //} List <DEdge> edges = graph.GetNeighbors(testV1); foreach (DEdge item in edges) { Console.WriteLine(item); } Console.WriteLine(GetEdge(graph, travel)); }
private void CreateDifferentiationGraph(DGraph graph) { DNode inNode = graph.AddNode("Di_in"); inNode.DrawingNode.Attr.Shape = MsaglShape.Circle; inNode.DrawingNode.Attr.FillColor = MsaglColor.Red; DNode precursorNode = Nesting_Cell_AddNode(graph, "Di_precursor", "Precursor"); DNode earlyMeiosisNode = Nesting_Cell_AddNode(graph, "Di_early_meiosis", "Early Meiosis"); DNode meiosisNode = Nesting_Cell_AddNode(graph, "Di_meiosis", "Meiosis"); DNode gameteNode = Nesting_Cell_AddNode(graph, "Di_gamete", null); Grid gameteContainer = new Grid(); gameteContainer.RowDefinitions.Add(new RowDefinition()); gameteContainer.RowDefinitions.Add(new RowDefinition()); gameteContainer.Children.Add(new TextBlock() { Text = "Gamete", TextAlignment = TextAlignment.Center, FontWeight = FontWeights.Bold }); gameteNode.Label = new DNestedGraphLabel(gameteNode, gameteContainer); DGraph gameteGraph = new DGraph(gameteNode.Label as DNestedGraphLabel) { Name = "Gamete" }; Nesting_CreateGameteGraph(gameteGraph); Grid.SetRow(gameteGraph, 1); gameteContainer.Children.Add(gameteGraph); (gameteNode.Label as DNestedGraphLabel).Graphs.Add(gameteGraph); Nesting_Cell_AddEdge(graph, inNode, precursorNode, null); Nesting_Cell_AddEdge(graph, precursorNode, earlyMeiosisNode, "GLD-1_Act\nOR\nGLD-2_Act"); Nesting_Cell_AddEdge(graph, earlyMeiosisNode, meiosisNode, "Pachytene"); Nesting_Cell_AddEdge(graph, meiosisNode, gameteNode, "MEK-2_Act\nAND\nMPK-1_Act"); }
private void Nesting_CreateMitosisGraph(DGraph graph) { DNode inNode = graph.AddNode("Mi_in"); inNode.DrawingNode.Attr.Shape = MsaglShape.Circle; inNode.DrawingNode.Attr.FillColor = MsaglColor.Red; DNode g0Node = Nesting_Cell_AddNode(graph, "Mi_g0", "G0"); DNode cycleNode = Nesting_Cell_AddNode(graph, "Mi_cycle", null); DGraph cycleGraph = new DGraph() { Name = "Mitosis Cycle" }; cycleGraph.ConfigureIncrementalLayout(); DNode c_G1_Node = Nesting_Cell_AddNode(cycleGraph, "Mi_cycle_G1", "G1"); DNode c_S_Node = Nesting_Cell_AddNode(cycleGraph, "Mi_cycle_S", "S"); DNode c_G2_Node = Nesting_Cell_AddNode(cycleGraph, "Mi_cycle_G2", "G2"); DNode c_M_Node = Nesting_Cell_AddNode(cycleGraph, "Mi_cycle_M", "M"); Nesting_Cell_AddEdge(cycleGraph, c_G1_Node, c_S_Node, null); Nesting_Cell_AddEdge(cycleGraph, c_S_Node, c_G2_Node, null); Nesting_Cell_AddEdge(cycleGraph, c_G2_Node, c_M_Node, null); cycleNode.Label = new DNestedGraphLabel(cycleNode, cycleGraph); Nesting_Cell_AddEdge(graph, cycleNode, g0Node, "exit cell\ncycle"); Nesting_Cell_AddEdge(graph, inNode, g0Node, null); DEdge g0_g1_edge = graph.AddEdgeBetweenNodes(g0Node, c_G1_Node); g0_g1_edge.DrawingEdge.Attr.Color = MsaglColor.Red;//*/ }
private void CreateMitosis(DGraph graph, DCluster mitosis) { var inNode = graph.AddNode("Mitosis_In"); graph.AddNodeToCluster(mitosis, inNode); inNode.DrawingNode.Attr.Shape = MsaglShape.Circle; inNode.DrawingNode.Attr.FillColor = MsaglColor.Red; var g0 = Clustering_Cell_AddNode(graph, mitosis, "G0", "G0"); var mitosis_cycle = graph.AddCluster(mitosis, "Mitosis_Cycle"); Clustering_ApplyNodeAttributes(mitosis_cycle); var g1 = Clustering_Cell_AddNode(graph, mitosis_cycle, "G1", "G1"); var s = Clustering_Cell_AddNode(graph, mitosis_cycle, "S", "S"); var g2 = Clustering_Cell_AddNode(graph, mitosis_cycle, "G2", "G2"); var m = Clustering_Cell_AddNode(graph, mitosis_cycle, "M", "M"); Clustering_Cell_AddEdge(graph, inNode, g0, null); Clustering_Cell_AddEdge(graph, g0, g1, null); Clustering_Cell_AddEdge(graph, g1, s, null); Clustering_Cell_AddEdge(graph, s, g2, null); Clustering_Cell_AddEdge(graph, g2, m, null); Clustering_Cell_AddEdge(graph, mitosis_cycle, g0, "exit cell\ncycle");//*/ }
private DNode Clustering_Cell_AddNode(DGraph graph, DCluster cluster, string id, string label) { var ret = graph.AddNode(id); if (label != null) { ret.Label = new DTextLabel(ret, label); } graph.AddNodeToCluster(cluster, ret); Clustering_ApplyNodeAttributes(ret); return(ret); }
private void Nesting_CreateGameteGraph(DGraph graph) { DNode inNode = graph.AddNode("Ga_in"); inNode.DrawingNode.Attr.Shape = MsaglShape.Circle; inNode.DrawingNode.Attr.FillColor = MsaglColor.Red; DNode splitterNode = graph.AddNode("Ga_sp"); splitterNode.DrawingNode.Attr.Shape = MsaglShape.Circle; splitterNode.DrawingNode.Attr.FillColor = MsaglColor.Blue; DNode spermNode = Nesting_Cell_AddNode(graph, "Ga_sperm", "Sperm"); DNode oocyteNode = Nesting_Cell_AddNode(graph, "Ga_oocyte", "Oocyte"); DNode matureOocyteNode = Nesting_Cell_AddNode(graph, "Ga_matureOocyte", "Mature\nOocyte"); DNode zygoteNode = Nesting_Cell_AddNode(graph, "Ga_zygote", "Zygote"); Nesting_Cell_AddEdge(graph, inNode, splitterNode, null); Nesting_Cell_AddEdge(graph, splitterNode, spermNode, "Sperm_Effector_Act"); Nesting_Cell_AddEdge(graph, splitterNode, oocyteNode, "Oocyte_Effector_Act"); Nesting_Cell_AddEdge(graph, oocyteNode, matureOocyteNode, "Maturation"); Nesting_Cell_AddEdge(graph, matureOocyteNode, zygoteNode, "Fertilization"); }
private DNode Nesting_Cell_AddNode(DGraph graph, string id, string label) { DNode ret = graph.AddNode(id); if (label != null) { ret.Label = new DTextLabel(ret, label); } ret.DrawingNode.Attr.Color = MsaglColor.Green; ret.DrawingNode.Attr.LineWidth = 2.0; ret.DrawingNode.Attr.Shape = MsaglShape.Box; ret.DrawingNode.Attr.XRadius = 5.0; ret.DrawingNode.Attr.YRadius = 5.0; return(ret); }
private void CreateDifferentiation(DGraph graph, DCluster differentiation) { var inNode = graph.AddNode("Differentiation_in"); inNode.DrawingNode.Attr.Shape = MsaglShape.Circle; inNode.DrawingNode.Attr.FillColor = MsaglColor.Red; graph.AddNodeToCluster(differentiation, inNode); var precursor = Clustering_Cell_AddNode(graph, differentiation, "Precursor", "Precursor"); var earlyMeiosis = Clustering_Cell_AddNode(graph, differentiation, "EarlyMeiosis", "Early Meiosis"); var meiosis = Clustering_Cell_AddNode(graph, differentiation, "Diff_Meiosis", "Meiosis"); var gamete = graph.AddCluster(differentiation, "Gamete"); Clustering_ApplyNodeAttributes(gamete); CreateGamete(graph, gamete); Clustering_Cell_AddEdge(graph, inNode, precursor, null); Clustering_Cell_AddEdge(graph, precursor, earlyMeiosis, "GLD-1_Act\nOR\nGLD-2_Act"); Clustering_Cell_AddEdge(graph, earlyMeiosis, meiosis, "Pachytene"); Clustering_Cell_AddEdge(graph, meiosis, gamete, "MEK-2_Act\nAND\nMPK-1_Act");//*/ }
private void CreateNestedGraph() { var g = GraphControlForNesting.Graph; // Create first nested graph. var inner1 = new DGraph() { Name = "Inner 1" }; var node11 = inner1.AddNode("ID1.1"); var node12 = inner1.AddNode("ID1.2"); var edge11_12 = inner1.AddEdgeBetweenNodes(node11, node12); // Create second nested graph. var inner3 = new DGraph() { Name = "Inner 2" }; var node31 = inner3.AddNode("ID3.1"); var node32 = inner3.AddNode("ID3.2"); var edge31_32 = inner3.AddEdgeBetweenNodes(node31, node32); // Create outer graph. var node1 = g.AddNode("ID1"); node1.Label = new DNestedGraphLabel(node1, inner1); node1.DrawingNode.Attr.Shape = Microsoft.Msagl.Drawing.Shape.Box; var node2 = g.AddNode("ID2"); var node3 = g.AddNode("ID3"); node3.Label = new DNestedGraphLabel(node3, inner3); node3.DrawingNode.Attr.Shape = Microsoft.Msagl.Drawing.Shape.Box; var edge1_2 = g.AddEdgeBetweenNodes(node1, node2); var edge2_3 = g.AddEdgeBetweenNodes(node2, node3); // Set some labels. node11.Label = new DTextLabel(node11) { Text = "Node 1.1" }; node12.Label = new DTextLabel(node12) { Text = "Node 1.2" }; node31.Label = new DTextLabel(node31) { Text = "Node 3.1" }; node32.Label = new DTextLabel(node32) { Text = "Node 3.2" }; node2.Label = new DTextLabel(node2) { Text = "Node 2" }; DEdge crossEdge1 = g.AddEdgeBetweenNodes(node11, node3); crossEdge1.Label = new DTextLabel(crossEdge1, "cross edge"); DEdge crossEdge2 = g.AddEdgeBetweenNodes(node12, node31); g.BeginLayout(); }
private void Nesting_CreateProliferationGraph(DGraph graph) { DNode inNode = graph.AddNode("Pr_in"); inNode.DrawingNode.Attr.Shape = MsaglShape.Circle; inNode.DrawingNode.Attr.FillColor = MsaglColor.Red; DNode mitosisNode = Nesting_Cell_AddNode(graph, "Pr_mitosis", null); Grid mitosisContainer = new Grid(); mitosisContainer.RowDefinitions.Add(new RowDefinition()); mitosisContainer.RowDefinitions.Add(new RowDefinition()); mitosisContainer.Children.Add(new TextBlock() { Text = "Mitosis", TextAlignment = TextAlignment.Center, FontWeight = FontWeights.Bold }); mitosisNode.Label = new DNestedGraphLabel(mitosisNode, mitosisContainer); DGraph mitosisGraph = new DGraph(mitosisNode.Label as DNestedGraphLabel) { Name = "Mitosis" }; Nesting_CreateMitosisGraph(mitosisGraph); Grid.SetRow(mitosisGraph, 1); mitosisContainer.Children.Add(mitosisGraph); (mitosisNode.Label as DNestedGraphLabel).Graphs.Add(mitosisGraph); DNode splitterNode = graph.AddNode("Pr_sp"); splitterNode.DrawingNode.Attr.Shape = MsaglShape.Circle; splitterNode.DrawingNode.Attr.FillColor = MsaglColor.Blue; DNode meiosisNode = Nesting_Cell_AddNode(graph, "Pr_meiosis", null); Grid meiosisContainer = new Grid(); meiosisContainer.RowDefinitions.Add(new RowDefinition()); meiosisContainer.RowDefinitions.Add(new RowDefinition()); meiosisContainer.Children.Add(new TextBlock() { Text = "Meiosis", TextAlignment = TextAlignment.Center, FontWeight = FontWeights.Bold }); meiosisNode.Label = new DNestedGraphLabel(meiosisNode, meiosisContainer); DGraph meiosisGraph = new DGraph(meiosisNode.Label as DNestedGraphLabel) { Name = "Meiosis" }; Nesting_CreateMeiosisGraph(meiosisGraph); Grid.SetRow(meiosisGraph, 1); meiosisContainer.Children.Add(meiosisGraph); (meiosisNode.Label as DNestedGraphLabel).Graphs.Add(meiosisGraph); Nesting_Cell_AddEdge(graph, inNode, mitosisNode, null); Nesting_Cell_AddEdge(graph, mitosisNode, splitterNode, "Early Meiosis"); DEdge splitter_g0_edge = graph.AddEdgeBetweenNodes(splitterNode, mitosisGraph.NodeMap["Mi_g0"]); splitter_g0_edge.DrawingEdge.Attr.Color = MsaglColor.Red; DEdge splitter_inter_edge = graph.AddEdgeBetweenNodes(splitterNode, meiosisGraph.NodeMap["Me_inter"]); splitter_inter_edge.DrawingEdge.Attr.Color = MsaglColor.Red;//*/ }