本文整理汇总了C#中IEdge类的典型用法代码示例。如果您正苦于以下问题:C# IEdge类的具体用法?C# IEdge怎么用?C# IEdge使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IEdge类属于命名空间,在下文中一共展示了IEdge类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
}
开发者ID:BgRva,项目名称:Blob1,代码行数:31,代码来源:BasicAdjList_As_INetworkChangeEventsFixture.cs
示例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");
}
开发者ID:sethjuarez,项目名称:numl,代码行数:12,代码来源:Graph.cs
示例3: AGSEdges
public AGSEdges(IEdge left, IEdge right, IEdge top, IEdge bottom)
{
Left = left;
Right = right;
Top = top;
Bottom = bottom;
}
开发者ID:tzachshabtay,项目名称:MonoAGS,代码行数:7,代码来源:AGSEdges.cs
示例4: ReversedEdge
public ReversedEdge(IEdge e)
{
if (e==null)
throw new ArgumentNullException("e");
this.wrapped = e;
}
开发者ID:BackupTheBerlios,项目名称:mbunit-svn,代码行数:7,代码来源:ReversedEdge.cs
示例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));
}
开发者ID:bidacek,项目名称:GraphTheoryEditor,代码行数:25,代码来源:NonOriented.cs
示例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];
}
开发者ID:timonela,项目名称:mb-unit,代码行数:13,代码来源:ResidualEdgePredicate.cs
示例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;
}
开发者ID:timonela,项目名称:mb-unit,代码行数:12,代码来源:FormatEdgeEventArgs.cs
示例8: AddEdge
public IEdge AddEdge(IEdge e)
{
if (e != null && Graph.Equals(e.Graph)) return e;
if(Graph.AddEdge(e))
return e;
return null;
}
开发者ID:kinghand,项目名称:KHGraphDB,代码行数:7,代码来源:GraphHelper.cs
示例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;
}
开发者ID:MingStar,项目名称:SimUniversity,代码行数:29,代码来源:SetupPlayer.cs
示例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;
}
开发者ID:Corne,项目名称:VOC,代码行数:28,代码来源:Board.cs
示例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);
}
开发者ID:lurongkai,项目名称:SuperNet,代码行数:7,代码来源:VertexRegister.cs
示例12: Test
public bool Test(IEdge e)
{
NamedEdge ne = e as NamedEdge;
if (ne==null)
return false;
return ne.Name == name;
}
开发者ID:BackupTheBerlios,项目名称:mbunit-svn,代码行数:7,代码来源:NameEqualPredicate.cs
示例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;
}
开发者ID:tzachshabtay,项目名称:MonoAGS,代码行数:7,代码来源:AGSEdges.cs
示例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]);
}
}
开发者ID:lurongkai,项目名称:SuperNet,代码行数:7,代码来源:Program.cs
示例15: FromEdges
public void FromEdges(IEdges edges)
{
Left = edges.Left;
Right = edges.Right;
Top = edges.Top;
Bottom = edges.Bottom;
}
开发者ID:tzachshabtay,项目名称:MonoAGS,代码行数:7,代码来源:AGSEdges.cs
示例16: Add
public void Add(IEdge item)
{
SaveVertex(item.From);
SaveVertex(item.To);
_edges.Add(item);
}
开发者ID:lurongkai,项目名称:SuperNet,代码行数:7,代码来源:Map.cs
示例17: GetValue
private static IComparable GetValue(this IPropertyDefinition myProperty, IEdge myEdge)
{
if (myProperty.RelatedType == null)
throw new ArgumentException("A property with nor related type is not allowed.");
if (!myProperty.RelatedType.Name.Equals(GlobalConstants.Edge))
return myEdge.GetProperty<IComparable>(myProperty.ID);
switch (myProperty.Name)
{
case GlobalConstants.EdgeDotComment:
return myEdge.Comment;
case GlobalConstants.EdgeDotCreationDate:
return myEdge.CreationDate;
case GlobalConstants.EdgeDotModificationDate:
return myEdge.ModificationDate;
case GlobalConstants.EdgeDotEdgeTypeID:
return myEdge.EdgeTypeID;
case GlobalConstants.EdgeDotEdgeTypeName:
return myProperty.RelatedType.GetDescendantTypesAndSelf().Where(_ => _.ID == myEdge.EdgeTypeID).Select(__ => __.Name).FirstOrDefault();
default:
throw new System.Exception(
"A new property was added to the edeg type Edge, but this switch stement was not changed.");
}
}
开发者ID:anukat2015,项目名称:sones,代码行数:31,代码来源:IPropertyDefintionExtension.cs
示例18: CalculateAttraction
/// <summary>
/// Calculates the attraction or tension on the given edge.
/// </summary>
/// <param name="edge">The edge.</param>
public void CalculateAttraction(IEdge edge)
{
INode n1, n2;
Params n1p = new Params();
Params n2p = new Params();
if (edge.SourceNode != null)
{
n2 = edge.SourceNode;
n2p = Pars[n2.Uid.ToString()];
};
if (edge.TargetNode != null)
{
n1 = edge.TargetNode;
n1p = Pars[n1.Uid.ToString()];
};
double xDelta = n1p.loc[0] - n2p.loc[0];
double yDelta = n1p.loc[1] - n2p.loc[1];
double deltaLength = Math.Max(EPSILON, Math.Sqrt(xDelta * xDelta + yDelta * yDelta));
double force = (deltaLength * deltaLength) / forceConstant;
if (Double.IsNaN(force))
{
System.Diagnostics.Trace.WriteLine("Oops, the layout resulted in a NaN problem.");
return;
}
double xDisp = (xDelta / deltaLength) * force;
double yDisp = (yDelta / deltaLength) * force;
n1p.disp[0] -= xDisp; n1p.disp[1] -= yDisp;
n2p.disp[0] += xDisp; n2p.disp[1] += yDisp;
}
开发者ID:JackWangCUMT,项目名称:mathnet-yttrium,代码行数:38,代码来源:FruchtermanReingoldLayout.cs
示例19: DrawParallelEdgeSelected
public static void DrawParallelEdgeSelected(Graphics g, IEdge e, IEnumerable<IEdge> es, Font f, PointF pSource, PointF pTarget, int Radius = 5)
{
var ps = pSource;
var pt = pTarget;
String s = "";
List<float> Heights = new List<float>();
foreach (var et in es)
{
string str = et.AttributesToString();
s += str;
Heights.Add(g.MeasureString(str, f).Height);
}
SizeF size = g.MeasureString(s, f);
PointF location = new PointF((pt.X * 2 + 3 * ps.X) / 5 - 4, (pt.Y * 2 + ps.Y * 3) / 5 - 4);
RectangleF rect = new RectangleF(location, size);
GraphicsPath roundedRect = GetRoundedRect(rect, Radius);
g.DrawLine(penHover, ps, pt);
g.FillEllipse(brushHover, (pt.X + ps.X) / 2 - 2, (pt.Y + ps.Y) / 2 - 2, 4, 4);
float hM = -1;
g.FillPath(brushAttrPanel, roundedRect);
foreach (var h in Heights)
{
hM += h;
g.DrawLine(penAttrBorderSlipt, location.X + Radius, location.Y + hM, location.X + size.Width - Radius, location.Y + hM);
}
g.DrawPath(penAttrBorder, roundedRect);
g.DrawString(s, f, brushText, rect);
}
开发者ID:kinghand,项目名称:KHGraphDB,代码行数:35,代码来源:Render.cs
示例20: Test
/// <summary>
///
/// </summary>
/// <param name="e"></param>
/// <returns></returns>
public bool Test(IEdge e)
{
if (e == null)
throw new ArgumentNullException("e");
return m_EdgePredicate.Test(e) && m_VertexPredicate.Test(e.Source);
}
开发者ID:taoxiease,项目名称:asegrp,代码行数:12,代码来源:InEdgePredicate.cs
注:本文中的IEdge类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论