本文整理汇总了C#中Graph.FindNode方法的典型用法代码示例。如果您正苦于以下问题:C# Graph.FindNode方法的具体用法?C# Graph.FindNode怎么用?C# Graph.FindNode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Graph
的用法示例。
在下文中一共展示了Graph.FindNode方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Analyze
private void Analyze(string dll)
{
if (!string.IsNullOrEmpty(dll))
{
toolStripStatusLabel1.Text = dll;
var graph = new Graph("glee");
richTextBox1.Clear();
richTextBox2.Clear();
foreach (string relation in _references)
{
if (relation.StartsWith(dll))
{
string[] strs = relation.Split(',');
graph.AddEdge(strs[0], strs[1]).Attr.Color=Microsoft.Glee.Drawing.Color.DarkBlue;
richTextBox1.AppendText(strs[1] + "\n");
graph.FindNode(strs[1]).Attr.Fillcolor = Microsoft.Glee.Drawing.Color.Blue;
}else if(relation.EndsWith(dll))
{
string[] strs = relation.Split(',');
graph.AddEdge(strs[0], strs[1]).Attr.Color = Microsoft.Glee.Drawing.Color.DarkRed;
richTextBox2.AppendText(strs[0] + "\n");
graph.FindNode(strs[0]).Attr.Fillcolor = Microsoft.Glee.Drawing.Color.Red;
}
}
var node=graph.FindNode(dll);
if(node !=null)node.Attr.Fillcolor = Microsoft.Glee.Drawing.Color.Green;
_viewer.Graph = graph;
_viewer.CalculateLayout(graph);
}
}
示例2: DFSAnimation
public bool DFSAnimation(Graph g, int sID, int eID)
{
if (g == null || g.nodes == null || g.nodes.Count == 0) return false;
graph = g;
start = graph.FindNode(sID);
end = graph.FindNode(eID);
if (start == null || end == null) return false;
// Set player in start node position
transform.position = start.Position + new Vector3(-0.5f, 0, 0);
ResetGraphForSearch();
StartCoroutine(DoDFSAnimation());
return true;
}
示例3: GenerateGraph
/// <summary>
/// Generate graph based on given Gridview. Should Represent a project schedule.
/// </summary>
/// <param name="rows"></param>
private Graph GenerateGraph(DataGridViewRowCollection rows)
{
Graph g = new Graph("Schedule");
List<Edge> startEdges = new List<Edge>();
Node start = g.AddNode("START");
start.Attr.Color = Microsoft.Glee.Drawing.Color.Green;
Node end = g.AddNode("END");
end.Attr.Color = Microsoft.Glee.Drawing.Color.Red;
if (rows.Count <= 0)
g.AddEdge(start.Id, end.Id);
foreach (DataGridViewRow row in rows)
{
if (row.Cells["pred"].Value == null)
throw new NullReferenceException("No Predecessor Found");
if (row.Cells["succ"].Value == null)
throw new NullReferenceException("No Successor Found");
String pred = row.Cells["pred"].Value.ToString();
String succ = row.Cells["succ"].Value.ToString();
String curr = row.Cells["name"].Value.ToString();
Node predNode = g.FindNode(pred);
Node succNode = g.FindNode(succ);
Node currNode = g.FindNode(curr);
if (currNode == null)
currNode= g.AddNode(curr);
if (predNode == null)
{
predNode = g.AddNode(pred);
g.AddEdge(predNode.Id, currNode.Id);
}
else if (predNode.Id.Equals(start.Id))
{
bool exists = false;
foreach (Edge ed in start.OutEdges)
{
if (ed.Target.Equals(currNode.Id))
{
exists = true;
break;
}
}
if(!exists)
g.AddEdge(start.Id, currNode.Id);
}
if (succNode == null)
{
succNode = g.AddNode(succ);
g.AddEdge(currNode.Id, succNode.Id);
}
else if (succNode.Id.Equals(end.Id))
{
bool exists = false;
foreach (Edge ed in end.InEdges)
{
if (ed.Source.Equals(currNode.Id))
{
exists = true;
break;
}
}
if (!exists)
g.AddEdge(currNode.Id, end.Id);
}
else
g.AddEdge(currNode.Id, succNode.Id);
}
return g;
}
示例4: render
/// <summary>
/// Pinta el grafo de la red en el canvas correspondiente
/// </summary>
public void render()
{
Graph graph = new Graph("MANET");
foreach (NetUserNode netUserNode in netUsersNodes)
{
graph.AddNode(netUserNode.Id.ToString());
Node node = graph.FindNode(netUserNode.Id.ToString());
switch (netUserNode.State)
{
case CommunicationQuality.NORMAL:
{
switch (netUserNode.Quality)
{
case NetUserQuality.NORMAL:
{
node.Attr.Fillcolor = Microsoft.Glee.Drawing.Color.LightGreen;
break;
}
case NetUserQuality.LOW:
{
node.Attr.Fillcolor = Microsoft.Glee.Drawing.Color.LightGreen;
break;
}
case NetUserQuality.CRITICAL:
{
node.Attr.Fillcolor = Microsoft.Glee.Drawing.Color.LightGreen;
break;
}
}
break;
}
case CommunicationQuality.OVERLOADED:
{
switch (netUserNode.Quality)
{
case NetUserQuality.NORMAL:
{
node.Attr.Fillcolor = Microsoft.Glee.Drawing.Color.Yellow;
break;
}
case NetUserQuality.LOW:
{
node.Attr.Fillcolor = Microsoft.Glee.Drawing.Color.Yellow;
break;
}
case NetUserQuality.CRITICAL:
{
node.Attr.Fillcolor = Microsoft.Glee.Drawing.Color.Yellow;
break;
}
}
break;
}
case CommunicationQuality.CRITICAL:
{
switch (netUserNode.Quality)
{
case NetUserQuality.NORMAL:
{
node.Attr.Fillcolor = Microsoft.Glee.Drawing.Color.Red;
break;
}
case NetUserQuality.LOW:
{
node.Attr.Fillcolor = Microsoft.Glee.Drawing.Color.Red;
break;
}
case NetUserQuality.CRITICAL:
{
node.Attr.Fillcolor = Microsoft.Glee.Drawing.Color.Red;
break;
}
}
break;
}
}
node.Attr.Fontcolor = Microsoft.Glee.Drawing.Color.DarkBlue;
node.Attr.Fontsize = 6;
node.Attr.Label = netUserNode.Name;
node.Attr.Shape = Microsoft.Glee.Drawing.Shape.Ellipse;
foreach (NetUserNode remoteNetUserNode in netUserNode.Links)
{
graph.AddEdge(netUserNode.Id.ToString(), remoteNetUserNode.Id.ToString());
}
}
viewer.Graph = graph;
viewer.Refresh();
}