本文整理汇总了C#中IEdge类的典型用法代码示例。如果您正苦于以下问题:C# IEdge类的具体用法?C# IEdge怎么用?C# IEdge使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IEdge类属于命名空间,在下文中一共展示了IEdge类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ChangeEventsEnabled_When_False_Prevents_NetworkChanged_Fired_When_RemoveEdge_Is_Called
public void ChangeEventsEnabled_When_False_Prevents_NetworkChanged_Fired_When_RemoveEdge_Is_Called(int nodeCount, int edgeCount, int edgesToRemove)
{
//Arrange
var net = new BasicAdjList(Guid.NewGuid());
Random rand = new Random();
for (int i = 0; i < nodeCount; i++)
net.CreateNode();
INode nodeA = null;
INode nodeB = null;
IEdge[] edges = new IEdge[edgeCount];
for (int i = 0; i < edgeCount; i++)
{
nodeA = net.Nodes[rand.Next(nodeCount)];
nodeB = net.Nodes[rand.Next(nodeCount)];
edges[i] = net.CreateEdge(nodeA, nodeB);
}
//---------------------
var helper = new NetworkChangedEventsTestHelper();
net.NetworkChanged += new NetworkChangedEventHandler<INetwork, NetworkChangedEventArgs>(helper.NetworkChanged_DummyHandler);
net.ChangeEventsEnabled = false;
for (int i = 0; i < edges.Length; i++)
{
net.RemoveEdge(edges[i]);
}
Assert.Equal(0, helper.NetworkChanged_TimesCalled);
}
示例2: AddEdge
/// <summary>
/// Inserts the Edge object to the Graph.
/// <para>Connecting IVertex objects should already be present in the graph before attempting to add a connection.</para>
/// </summary>
/// <param name="edge">IEdge object to add.</param>
public void AddEdge(IEdge edge)
{
if (_vertices.ContainsKey(edge.ParentId) && _vertices.ContainsKey(edge.ChildId))
_edges.AddOrUpdate(edge.ParentId, edge.ChildId, edge);
else
throw new InvalidOperationException("Invalid vertex index specified in edge");
}
示例3: AGSEdges
public AGSEdges(IEdge left, IEdge right, IEdge top, IEdge bottom)
{
Left = left;
Right = right;
Top = top;
Bottom = bottom;
}
示例4: ReversedEdge
public ReversedEdge(IEdge e)
{
if (e==null)
throw new ArgumentNullException("e");
this.wrapped = e;
}
示例5: addEdge
public void addEdge(IEdge e)
{
if (e == null) {return; }
//neplatný graf
if (!innerGraph.Vertices.Contains(e.Vertex_1) || !innerGraph.Vertices.Contains(e.Vertex_2)) { return; }
//multihrana
/*
foreach(Edge ed in innerGraph.Edges)
{
if ((ed.vertex_1 == e.vertex_1 && ed.vertex_2 == e.vertex_2) || (ed.vertex_1 == e.vertex_2 && ed.vertex_2 == e.vertex_1))
{
return;
}
}
*/
if (GraphForEdit.Edges.Contains(e, GraphForEdit.getEdgeComparer())) { return; }
innerGraph.Edges.Add(e);
if (eHandler != null) eHandler(this, new EdgeChangeArgs(e, ChangeType.Add));
}
示例6: Test
/// <summary>
/// Test if edge e has a positive residual capacity
/// </summary>
/// <param name="e">edge to test</param>
/// <returns>0 < ResidualCapacities[e]</returns>
/// <exception cref="ArgumentNullException">e is null</exception>
public bool Test(IEdge e)
{
if (e == null)
throw new ArgumentNullException("e");
return 0 < (double)this.residualCapacities[e];
}
示例7: FormatEdgeEventArgs
/// <summary>
/// Graphviz format edge parameter object
/// </summary>
/// <param name="edgeFormatter">edge formatter</param>
/// <param name="e">edge</param>
public FormatEdgeEventArgs(GraphvizEdge edgeFormatter, IEdge e)
: base(e)
{
if (edgeFormatter==null)
throw new ArgumentNullException("edgeFormatter");
m_EdgeFormatter = edgeFormatter;
}
示例8: AddEdge
public IEdge AddEdge(IEdge e)
{
if (e != null && Graph.Equals(e.Graph)) return e;
if(Graph.AddEdge(e))
return e;
return null;
}
示例9: GetEdgeScore
private double GetEdgeScore(IEdge edge, HashSet<IEdge> checkedEdges,
Dictionary<IVertex, double> vertexScores, int level)
{
if (checkedEdges.Contains(edge))
{
return 0.0;
}
checkedEdges.Add(edge);
double score = 0.0;
// get adjacent vertex scores
foreach (IVertex vertex in edge.Adjacent.Vertices)
{
if (vertexScores.ContainsKey(vertex))
{
score += vertexScores[vertex];
vertexScores.Remove(vertex);
}
}
score /= level;
// other edge scores
foreach (IEdge nextEdge in edge.Adjacent.Edges)
{
if (nextEdge.Color == null)
{
score += GetEdgeScore(nextEdge, checkedEdges, vertexScores, level + 1);
}
}
return score;
}
示例10: BuildRoad
public IRoad BuildRoad(IEdge edge, IPlayer owner)
{
if (edge == null)
throw new ArgumentNullException(nameof(edge));
if (owner == null)
throw new ArgumentNullException(nameof(owner));
if (!Edges.Contains(edge))
throw new ArgumentException("Edge does not exist on the board");
if (roads.Any(r => r.Edge == edge))
throw new ArgumentException("There already is a road build on the given edge");
if (Tiles.Where(t => t.IsAdjacentTo(edge)).All(t => t.Rawmaterial == MaterialType.Sea))
throw new ArgumentException("Can't build roads on sea!");
var adjacentVertices = Vertices.Where(v => v.IsAdjacentTo(edge));
var adjacentEdges = Edges.Where(e => e.IsAdjacentTo(edge));
//CvB Todo: fix readability
if (establishments.All(e => !adjacentVertices.Contains(e.Vertex) || e.Owner != owner) &&
roads.All(r => !adjacentEdges.Contains(r.Edge) || r.Owner != owner))
throw new ArgumentException("Road should have an adjacent establisment or road of the player");
var road = new Road(edge, owner);
roads.Add(road);
logger.Info($"Road build; Player {owner.Name}, {edge.ToString()}");
return road;
}
示例11: UpdateRegister
internal void UpdateRegister(VertexRegister milestoneRegister, IEdge edge)
{
TotalWeight = milestoneRegister.TotalWeight + edge.Weight;
EdgeTracks.Clear();
EdgeTracks = milestoneRegister.EdgeTracks.Select(et => et).ToList();
EdgeTracks.Add(edge);
}
示例12: Test
public bool Test(IEdge e)
{
NamedEdge ne = e as NamedEdge;
if (ne==null)
return false;
return ne.Name == name;
}
示例13: checkEdgeCross
private bool checkEdgeCross(IEdge edge, float previous, float current, Func<IEdge,float,float,bool> check)
{
if (!edge.Enabled) return false;
if (!check(edge,previous,current)) return false;
edge.OnEdgeCrossed.Invoke(edge, new AGSEventArgs());
return true;
}
示例14: PrintEdgeTrack
private static void PrintEdgeTrack(IEdge[] edge)
{
Console.WriteLine("Edge tracks:");
for (int i = 0; i < edge.Count(); i++) {
Console.WriteLine("{0}: {1}", i + 1, edge[i]);
}
}
示例15: FromEdges
public void FromEdges(IEdges edges)
{
Left = edges.Left;
Right = edges.Right;
Top = edges.Top;
Bottom = edges.Bottom;
}