本文整理汇总了C#中Microsoft.Msagl.Drawing.Graph.FindNode方法的典型用法代码示例。如果您正苦于以下问题:C# Graph.FindNode方法的具体用法?C# Graph.FindNode怎么用?C# Graph.FindNode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Msagl.Drawing.Graph
的用法示例。
在下文中一共展示了Graph.FindNode方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SomeClass
public static void SomeClass()
{
var graph = new MSAGL.Drawing.Graph("");
graph.AddEdge("A", "B");
graph.AddEdge("A", "B");
graph.FindNode("A").Attr.FillColor = MSAGL.Drawing.Color.BlanchedAlmond;
graph.FindNode("B").Attr.FillColor = MSAGL.Drawing.Color.BurlyWood;
var renderer = new MSAGL.GraphViewerGdi.GraphRenderer(graph);
renderer.CalculateLayout();
const int width = 50;
int height = (int)(graph.Height * (width / graph.Width));
const PixelFormat pixfmt = System.Drawing.Imaging.PixelFormat.Format32bppPArgb;
using (var bitmap = new System.Drawing.Bitmap(width, height, pixfmt))
{
using (var gfx = System.Drawing.Graphics.FromImage(bitmap))
{
gfx.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
gfx.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
gfx.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
var rect = new System.Drawing.Rectangle(0, 0, bitmap.Width, bitmap.Height);
renderer.Render(gfx, rect);
bitmap.Save("test.png");
}
}
}
示例2: CopyGraph
/// <summary>
/// Copies a graph and its GeometryGraph.
/// </summary>
/// <param name="parentGraph"></param>
/// <returns></returns>
public static Graph CopyGraph(Graph parentGraph)
{
GeometryGraph geometryCopy = CopyGraph(parentGraph.GeometryGraph);
Graph graph=new Graph();
graph.GeometryGraph = geometryCopy;
Dictionary<Node,int> nodeId=new Dictionary<Node, int>(geometryCopy.Nodes.Count);
for (int i = 0; i < geometryCopy.Nodes.Count; i++) {
nodeId[geometryCopy.Nodes[i]] = i;
String id = i.ToString();
graph.AddNode(id);
var node = graph.FindNode(id);
node.GeometryNode = geometryCopy.Nodes[i];
geometryCopy.Nodes[i].UserData = node;
}
foreach (var edge in geometryCopy.Edges) {
String sourceId = nodeId[edge.Source].ToString();
String targetId = nodeId[edge.Target].ToString();
var edgeCopy=graph.AddEdge(sourceId, "", targetId);
edgeCopy.GeometryEdge = edge;
edge.UserData = edgeCopy;
}
return graph;
}
示例3: Form1
public Form1()
{
InitializeComponent();
GViewer gViewer = new GViewer() { Dock = DockStyle.Fill };
SuspendLayout();
Controls.Add(gViewer);
ResumeLayout();
Graph graph = new Graph();
var sugiyamaSettings = (SugiyamaLayoutSettings)graph.LayoutAlgorithmSettings;
sugiyamaSettings.NodeSeparation *= 2;
graph.AddEdge("A", "B");
graph.AddEdge("A", "C");
graph.AddEdge("A", "D");
graph.LayerConstraints.PinNodesToSameLayer(new[] { graph.FindNode("A"), graph.FindNode("B"), graph.FindNode("C") });
gViewer.Graph = graph;
}
示例4: Dn
static Node Dn(Graph g, string s)
{
return g.FindNode(s);
}
示例5: CreateGraph
private void CreateGraph() {
Graph graph = new Graph("graph");
graph.Attr.BackgroundColor = Color.DodgerBlue;
Edge edge = (Edge)graph.AddEdge("S24", "27");
edge.LabelText = "Edge Label Test";
graph.AddEdge("S24", "25");
edge = graph.AddEdge("S1", "10") as Edge;
edge.LabelText = "Init";
edge.Attr.ArrowheadAtTarget = ArrowStyle.Tee;
// edge.Attr.Weight = 10;
edge = graph.AddEdge("S1", "2") as Edge;
// edge.Attr.Weight = 10;
graph.AddEdge("S35", "36");
graph.AddEdge("S35", "43");
graph.AddEdge("S30", "31");
graph.AddEdge("S30", "33");
graph.AddEdge("9", "42");
graph.AddEdge("9", "T1");
graph.AddEdge("25", "T1");
graph.AddEdge("25", "26");
graph.AddEdge("27", "T24");
graph.AddEdge("2", "3");
graph.AddEdge("2", "16");
graph.AddEdge("2", "17");
graph.AddEdge("2", "T1");
graph.AddEdge("2", "18");
graph.AddEdge("10", "11");
graph.AddEdge("10", "14");
graph.AddEdge("10", "T1");
graph.AddEdge("10", "13");
graph.AddEdge("10", "12");
graph.AddEdge("31", "T1");
edge = (Edge)graph.AddEdge("31", "32");
edge.Attr.ArrowheadAtTarget = ArrowStyle.Tee;
edge.Attr.LineWidth = 10;
edge.Attr.Weight = 10;
edge.Attr.ArrowheadLength *= 2;
edge = (Edge)graph.AddEdge("33", "T30");
edge.Attr.LineWidth = 15;
edge.Attr.AddStyle(Microsoft.Msagl.Drawing.Style.Dashed);
graph.AddEdge("33", "34");
graph.AddEdge("42", "4");
graph.AddEdge("26", "4");
graph.AddEdge("3", "4");
graph.AddEdge("16", "15");
graph.AddEdge("17", "19");
graph.AddEdge("18", "29");
graph.AddEdge("11", "4");
graph.AddEdge("14", "15");
graph.AddEdge("37", "39");
graph.AddEdge("37", "41");
graph.AddEdge("37", "38");
graph.AddEdge("37", "40");
graph.AddEdge("13", "19");
graph.AddEdge("12", "29");
graph.AddEdge("43", "38");
graph.AddEdge("43", "40");
graph.AddEdge("36", "19");
graph.AddEdge("32", "23");
graph.AddEdge("34", "29");
graph.AddEdge("39", "15");
graph.AddEdge("41", "29");
graph.AddEdge("38", "4");
graph.AddEdge("40", "19");
graph.AddEdge("4", "5");
graph.AddEdge("19", "21");
graph.AddEdge("19", "20");
graph.AddEdge("19", "28");
graph.AddEdge("5", "6");
graph.AddEdge("5", "T35");
graph.AddEdge("5", "23");
edge = graph.AddEdge("21", "22");
edge.Attr.ArrowheadLength *= 3;
graph.AddEdge("20", "15");
graph.AddEdge("28", "29");
graph.AddEdge("6", "7");
graph.AddEdge("15", "T1");
graph.AddEdge("22", "23");
graph.AddEdge("22", "T35");
graph.AddEdge("29", "T30");
graph.AddEdge("7", "T8");
graph.AddEdge("23", "T24");
graph.AddEdge("23", "T1");
Node node = graph.FindNode("S1") as Node;
node.LabelText = "Label Test";
CreateSourceNode(graph.FindNode("S1") as Node);
CreateSourceNode(graph.FindNode("S24") as Node);
CreateSourceNode(graph.FindNode("S35") as Node);
CreateTargetNode(graph.FindNode("T24") as Node);
CreateTargetNode(graph.FindNode("T1") as Node);
CreateTargetNode(graph.FindNode("T30") as Node);
CreateTargetNode(graph.FindNode("T8") as Node);
//.........这里部分代码省略.........
示例6: ProcessPhyloEdges
void ProcessPhyloEdges(Graph graph, GeometryGraph msaglGraph) {
foreach (Edge e in graph.Edges) {
Core.Layout.Node sourceNode = nodeMapping[e.SourceNode];
Core.Layout.Node targetNode = nodeMapping[e.TargetNode];
if (sourceNode == null) {
sourceNode = CreateGeometryNode(graph, msaglGraph, graph.FindNode(e.Source),
ConnectionToGraph.Connected);
nodeMapping[e.SourceNode] = sourceNode;
}
if (targetNode == null) {
targetNode = CreateGeometryNode(graph, msaglGraph, graph.FindNode(e.Target),
ConnectionToGraph.Connected);
nodeMapping[e.TargetNode] = targetNode;
}
Core.Layout.Edge msaglEdge = new Prototype.Phylo.PhyloEdge(sourceNode, targetNode);
msaglEdge.Weight = e.Attr.Weight;
msaglEdge.Separation = e.Attr.Separation;
if (e.Attr.ArrowAtSource) {
msaglEdge.EdgeGeometry.SourceArrowhead = new Arrowhead {Length = e.Attr.ArrowheadLength};
}
if (e.Attr.ArrowAtTarget) {
msaglEdge.EdgeGeometry.TargetArrowhead = new Arrowhead {Length = e.Attr.ArrowheadLength};
}
msaglGraph.Edges.Add(msaglEdge);
msaglEdge.UserData = e;
msaglEdge.LineWidth = e.Attr.LineWidth;
}
}
示例7: addNode
private void addNode(Graph g, string label)
{
g.AddNode(label);
g.FindNode(label).UserData = new NodeData();
}
示例8: CreateAndLayoutAndDisplayGraph
//.........这里部分代码省略.........
// graph.AddEdge("34", "35");
// graph.AddEdge("34", "36");
// graph.AddEdge("20", "34");
// graph.AddEdge("29", "34");
// graph.AddEdge("5", "34");
// graph.AddEdge("2", "34");
// graph.AddEdge("8", "34");
// graph.AddEdge("17", "34");
// graph.AddEdge("37", "38");
// graph.AddEdge("37", "39");
// graph.AddEdge("29", "37");
// graph.AddEdge("5", "37");
// graph.AddEdge("20", "37");
// graph.AddEdge("8", "37");
// graph.AddEdge("2", "37");
// graph.AddEdge("40", "41");
// graph.AddEdge("40", "42");
// graph.AddEdge("17", "40");
// graph.AddEdge("2", "40");
// graph.AddEdge("8", "40");
// graph.AddEdge("5", "40");
// graph.AddEdge("20", "40");
// graph.AddEdge("29", "40");
// graph.AddEdge("43", "44");
// graph.AddEdge("43", "45");
// graph.AddEdge("8", "43");
// graph.AddEdge("2", "43");
// graph.AddEdge("20", "43");
// graph.AddEdge("17", "43");
// graph.AddEdge("5", "43");
// graph.AddEdge("29", "43");
// graph.AddEdge("46", "47");
// graph.AddEdge("46", "48");
// graph.AddEdge("29", "46");
// graph.AddEdge("5", "46");
// graph.AddEdge("17", "46");
// graph.AddEdge("49", "50");
// graph.AddEdge("49", "51");
// graph.AddEdge("5", "49");
// graph.AddEdge("2", "49");
// graph.AddEdge("52", "53");
// graph.AddEdge("52", "54");
// graph.AddEdge("17", "52");
// graph.AddEdge("20", "52");
// graph.AddEdge("2", "52");
// graph.AddEdge("50", "52");
// graph.AddEdge("55", "56");
// graph.AddEdge("55", "57");
// graph.AddEdge("58", "59");
// graph.AddEdge("58", "60");
// graph.AddEdge("20", "58");
// graph.AddEdge("29", "58");
// graph.AddEdge("5", "58");
// graph.AddEdge("47", "58");
//
// var subgraph = new Subgraph("subgraph 1");
// graph.RootSubgraph.AddSubgraph(subgraph);
// subgraph.AddNode(graph.FindNode("47"));
// subgraph.AddNode(graph.FindNode("58"));
//
// graph.AddEdge(subgraph.Id, "55");
//
// var node = graph.FindNode("5");
// node.LabelText = "Label of node 5";
// node.Label.FontSize = 5;
// node.Label.FontName = "New Courier";
// node.Label.FontColor = Microsoft.Msagl.Drawing.Color.Blue;
//
// node = graph.FindNode("55");
//
//
// graph.Attr.LayerDirection= LayerDirection.LR;
// // graph.LayoutAlgorithmSettings.EdgeRoutingSettings.RouteMultiEdgesAsBundles = true;
// //graph.LayoutAlgorithmSettings.EdgeRoutingSettings.EdgeRoutingMode = EdgeRoutingMode.SplineBundling;
// //layout the graph and draw it
Graph graph = new Graph();
graph.AddEdge("47", "58");
graph.AddEdge("70", "71");
var subgraph = new Subgraph("subgraph1");
graph.RootSubgraph.AddSubgraph(subgraph);
subgraph.AddNode(graph.FindNode("47"));
subgraph.AddNode(graph.FindNode("58"));
var subgraph2 = new Subgraph("subgraph2");
subgraph2.Attr.Color = Color.Black;
subgraph2.Attr.FillColor = Color.Yellow;
subgraph2.AddNode(graph.FindNode("70"));
subgraph2.AddNode(graph.FindNode("71"));
subgraph.AddSubgraph(subgraph2);
graph.AddEdge("58", subgraph2.Id);
graph.Attr.LayerDirection = LayerDirection.LR;
graphViewer.Graph = graph;
}
catch (Exception e)
{
MessageBox.Show(e.ToString(), "Load Failed", MessageBoxButton.OK, MessageBoxImage.Error);
}
}
示例9: Create_Graph
public static void Create_Graph(List<note_node> DTArray)
{
int index;
//String Temp_str = null;
System.Windows.Forms.Form GDIForm = new System.Windows.Forms.Form();
GDIForm.Size = new System.Drawing.Size(1000, 1000);
//GDIForm.WindowState = FormWindowState.Maximized;
//create a viewer object
GViewerewer = new Microsoft.Msagl.GraphViewerGdi.GViewer();
//create a graph object
Microsoft.Msagl.Drawing.Graph graph = new Microsoft.Msagl.Drawing.Graph("graph");
//Sort DT Awway by position
List<note_node> sorted_list = DTArray.OrderBy(o => o.NoteDetails.position).ToList();
foreach (note_node temp_node in sorted_list)
{
index = DTArray.IndexOf(temp_node);
String Parent_Note;
String Current_Note;
// Check if it's a route node
if (temp_node.parent_node == null)
{
// Route node so skip
Current_Note = temp_node.ToStringSmall() + " Index" + temp_node.tree_index;
Node graph_node = new Node(Current_Note);
Microsoft.Msagl.Drawing.Color tempcolor = new Microsoft.Msagl.Drawing.Color();
graph_node.Attr.FillColor = Color.AliceBlue;
graph_node.Attr.Shape = Shape.Diamond;
graph.AddNode(graph_node);
}
else
{
//Build the Node string values
//Parent_Note = temp_node.parent_node_index.GetValueOrDefault().ToString() + "\r\n" + DTArray[temp_node.parent_node_index.GetValueOrDefault()].ToStringSmall();
///Current_Note = DTArray.IndexOf(temp_node).ToString() + "\r\n" + temp_node.ToStringSmall();
Parent_Note = temp_node.parent_node.ToStringSmall() + " Index" + temp_node.parent_node.tree_index;
Current_Note = temp_node.ToStringSmall() + " Index" + temp_node.tree_index;
//Current_Note = temp_node.ToStringSmall();
// 255,0,0 = Red
// 0,255,0 = Green
// Not route node so add edge details
graph.AddEdge(Parent_Note, temp_node.cost.ToString(), Current_Note);
//graph.AddNode()
//Microsoft.Msagl.Drawing.Color tempcol = Microsoft.Msagl.Drawing.Color.
// FromArgb(255,255,255);
if (temp_node.Excluded)
{
graph.FindNode(Current_Note).Attr.FillColor = Color.Red;
}
}
}
//bind the graph to the viewer
GViewerewer.Graph = graph;
//GViewerewer.Size = new System.Drawing.Size(800, 800);
//associate the viewer with the GDIForm
GDIForm.SuspendLayout();
GViewerewer.Dock = System.Windows.Forms.DockStyle.Fill;
GDIForm.Controls.Add(GViewerewer);
GDIForm.ResumeLayout();
//show the GDIForm
GDIForm.Show();
}
示例10: AddSchemaBox
static Node AddSchemaBox(Hashtable table, string uri, Graph g) {
Node b1;
if (table.ContainsKey(uri)) {
b1 = (Node) table[uri];
} else {
// Make sure labels are unique.
string baseLabel = GetFileName(uri);
string label = baseLabel;
int count = 0;
Node found = g.FindNode(baseLabel);
while (found != null) {
count++;
label = baseLabel + "(" + count + ")";
found = g.FindNode(label);
}
b1 = g.AddNode(uri);
SetNodeColors(b1);
b1.Attr.Shape = Shape.Box;
b1.LabelText = label;
b1.Attr.XRadius = b1.Attr.YRadius = 2; // rounded box.
b1.Attr.LabelMargin = 5;
table[uri] = b1;
}
return b1;
}
示例11: BuildGraphFrom
private Graph BuildGraphFrom(VisualGraphGeneratedMessage affectedGraph)
{
var graph = new Graph("graph")
{
Attr = {BackgroundColor = Color.Transparent}
};
if (affectedGraph.Connections != null)
{
_gViewer.LayoutAlgorithmSettingsButtonVisible = true;
_gViewer.ForeColor = System.Drawing.Color.FromArgb(1,2,3);
foreach (var x in affectedGraph.Connections)
{
var edge = graph.AddEdge(x.From, x.To);
if (_mode == DisplayMode.Dark)
{
edge.Attr.Color = Color.White;
}
}
}
graph.Attr.LayerDirection = LayerDirection.LR;
if (affectedGraph.Nodes != null)
foreach (var y in affectedGraph.Nodes)
{
var n = graph.FindNode(y.FullName) ?? graph.AddNode(y.FullName);
n.LabelText = y.DisplayName;
n.Attr.Shape = Shape.Box;
if (y.IsRootNode)
n.Attr.FillColor = Color.LightGreen;
else if (y.IsChange)
n.Attr.FillColor = Color.Maroon;
else if (y.IsTest && y.IsProfiledTest)
n.Attr.FillColor = Color.Yellow;
else if (y.IsTest)
n.Attr.FillColor = Color.DarkGoldenrod;
else if (y.IsInterface)
n.Attr.FillColor = Color.LightBlue;
//TODO GREG PUT ON FEATURE TOGGLE
else if (false && y.Complexity > 15)
n.Attr.FillColor = Color.LightPink;
else
n.Attr.FillColor = Color.White;
}
return graph;
}
示例12: CreateGraph
void CreateGraph()
{
#if DEBUG
DisplayGeometryGraph.SetShowFunctions();
#endif
Graph graph = new Graph();
graph.AddEdge("47", "58");
graph.AddEdge("70", "71");
var subgraph = new Subgraph("subgraph1");
graph.RootSubgraph.AddSubgraph(subgraph);
subgraph.AddNode(graph.FindNode("47"));
subgraph.AddNode(graph.FindNode("58"));
var subgraph2 = new Subgraph("subgraph2");
subgraph2.Attr.Color = Color.Black;
subgraph2.Attr.FillColor = Color.Yellow;
subgraph2.AddNode(graph.FindNode("70"));
subgraph2.AddNode(graph.FindNode("71"));
subgraph.AddSubgraph(subgraph2);
graph.AddEdge("58", subgraph2.Id);
graph.Attr.LayerDirection = LayerDirection.LR;
gViewer.Graph = graph;
// Graph graph = new Graph("graph");
// //graph.LayoutAlgorithmSettings=new MdsLayoutSettings();
// gViewer.BackColor = System.Drawing.Color.FromArgb(10, System.Drawing.Color.Red);
//
// /*
// 4->5
//5->7
//7->8
//8->22
//22->24
//*/
//
// //int wm = 80;
// graph.AddEdge("1", "2");
// graph.AddEdge("1", "3");
// var e = graph.AddEdge("4", "5");
// //e.Attr.Weight *= wm;
// e.Attr.Color = Color.Red;
// e.Attr.LineWidth *= 2;
//
// e = graph.AddEdge("4", "6");
// e.LabelText = "Changing label";
// this.labelToChange = e.Label;
// e=graph.AddEdge("7", "8");
// //e.Attr.Weight *= wm;
// e.Attr.LineWidth *= 2;
// e.Attr.Color = Color.Red;
//
// graph.AddEdge("7", "9");
// e=graph.AddEdge("5", "7");
// //e.Attr.Weight *= wm;
// e.Attr.Color = Color.Red;
// e.Attr.LineWidth *= 2;
//
// graph.AddEdge("2", "7");
// graph.AddEdge("10", "11");
// graph.AddEdge("10", "12");
// graph.AddEdge("2", "10");
// graph.AddEdge("8", "10");
// graph.AddEdge("5", "10");
// graph.AddEdge("13", "14");
// graph.AddEdge("13", "15");
// graph.AddEdge("8", "13");
// graph.AddEdge("2", "13");
// graph.AddEdge("5", "13");
// graph.AddEdge("16", "17");
// graph.AddEdge("16", "18");
// graph.AddEdge("19", "20");
// graph.AddEdge("19", "21");
// graph.AddEdge("17", "19");
// graph.AddEdge("2", "19");
// graph.AddEdge("22", "23");
//
// e=graph.AddEdge("22", "24");
// //e.Attr.Weight *= wm;
// e.Attr.Color = Color.Red;
// e.Attr.LineWidth *= 2;
//
// e = graph.AddEdge("8", "22");
// //e.Attr.Weight *= wm;
// e.Attr.Color = Color.Red;
// e.Attr.LineWidth *= 2;
//
// graph.AddEdge("20", "22");
// graph.AddEdge("25", "26");
// graph.AddEdge("25", "27");
// graph.AddEdge("20", "25");
// graph.AddEdge("28", "29");
// graph.AddEdge("28", "30");
// graph.AddEdge("31", "32");
// graph.AddEdge("31", "33");
// graph.AddEdge("5", "31");
// graph.AddEdge("8", "31");
// graph.AddEdge("2", "31");
// graph.AddEdge("20", "31");
// graph.AddEdge("17", "31");
// graph.AddEdge("29", "31");
//.........这里部分代码省略.........