本文整理汇总了C#中System.Edge类的典型用法代码示例。如果您正苦于以下问题:C# Edge类的具体用法?C# Edge怎么用?C# Edge使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Edge类属于System命名空间,在下文中一共展示了Edge类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddEdge
public void AddEdge(Edge e)
{
int v = e.Either, w = e.Other(v);
adj[v].Add(e);
adj[w].Add(e);
E++;
}
示例2: FindAndUnion
private static bool FindAndUnion(List<HashSet<Node>> trees, Edge currentEdge)
{
Node[] nodes = new Node[] { currentEdge.Start, currentEdge.End };
int firstTreeIndex = 0;
int secondTreeIndex = 0;
for (int i = 0; i < trees.Count; i++)
{
if (trees[i].IsSupersetOf(nodes))
{
return false;
}
if (trees[i].Contains(currentEdge.Start))
{
firstTreeIndex = i;
continue;
}
if (trees[i].Contains(currentEdge.End))
{
secondTreeIndex = i;
continue;
}
}
trees[firstTreeIndex].UnionWith(trees[secondTreeIndex]);
trees.RemoveAt(secondTreeIndex);
return true;
}
示例3: FindPath
private void FindPath(int startNode)
{
List<int> unprocessedNodesIdxs = new List<int>();
foreach(var n in _Graph.Keys)
{
_ClosestNodes[n] = new Edge { Distance = decimal.MaxValue };
unprocessedNodesIdxs.Add(n);
}
_ClosestNodes[startNode].Distance = 0;
while(unprocessedNodesIdxs.Count > 0)
{
var currentNodeIdx = unprocessedNodesIdxs.First(p => _ClosestNodes[p].Distance == unprocessedNodesIdxs.Min(pp => _ClosestNodes[pp].Distance));
unprocessedNodesIdxs.Remove(currentNodeIdx);
foreach(var outEdge in _Graph[currentNodeIdx])
{
decimal currentDistance = _ClosestNodes[outEdge.NextNodeId].Distance;
decimal newDistance = Math.Min(currentDistance, _ClosestNodes[currentNodeIdx].Distance + outEdge.EdgeVeight);
if(newDistance < currentDistance)
{
_ClosestNodes[outEdge.NextNodeId].Distance = newDistance;
_ClosestNodes[outEdge.NextNodeId].NextNodeId = currentNodeIdx;
}
}
}
}
示例4: setUpByEdge
public void setUpByEdge(Edge TempEdge,bool isBothWay)
{
var result = TableOfMazes.Select(i =>
{
if (i.VertexNumber == TempEdge.Source()) i.Neigboors.Add(TempEdge.Dest());
return i;
}).ToList();
if (isBothWay)
{
var resultTwo = TableOfMazes.Select(i =>
{
if (i.VertexNumber == TempEdge.Dest()) i.Neigboors.Add(TempEdge.Source());
return i;
}).ToList();
}
// var temp = TableOfMazes.FirstOrDefault(c => c.VertexNumber == TempEdge.Source());
// if (temp != null)
// {
// Debug.WriteLine("kjhjkhjkhjk");
// // temp.Neigboors.Add(TempEdge.Dest());
//// }
// var temp = TableOfMazes.Find(r => (r.VertexNumber == TempEdge.Source()));
// temp.Neigboors.Add(TempEdge.Dest());
// TableOfMazes.ElementAt(r => (r.VertexNumber == TempEdge.Source())).Neigboors.Add(TempEdge.Dest());
// TableOfMazes.ElementAtOrDefault(TempEdge.Source());
// TableOfMazes
}
示例5: TabStub
public TabStub(VisualStyle style)
{
// Default state
_wct = null;
_style = style;
_hoverOver = -1;
_hoverItem = -1;
_selectedIndex = -1;
_defaultFont = true;
_defaultColor = true;
_edge = Edge.None;
_drawTabs = new ArrayList();
_tabPages = new TabPageCollection();
base.Font = SystemInformation.MenuFont;
// Hookup to collection events
_tabPages.Cleared += new CollectionClear(OnClearedPages);
_tabPages.Inserted += new CollectionChange(OnInsertedPage);
_tabPages.Removing += new CollectionChange(OnRemovingPage);
_tabPages.Removed += new CollectionChange(OnRemovedPage);
// Need notification when the MenuFont is changed
Microsoft.Win32.SystemEvents.UserPreferenceChanged += new
UserPreferenceChangedEventHandler(OnPreferenceChanged);
// Default default colors
DefineBackColor(SystemColors.Control);
// Create the Timer for handling hovering over items
_hoverTimer = new Timer();
_hoverTimer.Interval = _hoverInterval;
_hoverTimer.Tick += new EventHandler(OnTimerExpire);
}
示例6: RemoveEdge
public void RemoveEdge(Edge aEdge)
{
if (aEdge != null && mEdges.Contains(aEdge))
mEdges.Remove(aEdge);
else
throw new GraphException("hrana v grafu neexistuje", GraphExampleMessageType.EDGE);
}
示例7: TransformeEdge
/// <summary>
/// This method is used for making EdgeWrapper object that can be sent on clint, from Edge<Guid, EdgeData>.
/// </summary>
/// <param name="edge">data that need to be sent to client</param>
/// <returns>EdgeWrapper object that is prepared for sending</returns>
public static EdgeWrapper TransformeEdge(Edge<Guid, EdgeData> edge)
{
EdgeWrapper edgeDataWraper = new EdgeWrapper();
edgeDataWraper.ToNodeId = edge.ToNodeId;
edgeDataWraper.Data = EdgeDataWrapper.TransformeEdgeData(edge.Data);
return edgeDataWraper;
}
示例8: AddGraphNode
/// <summary>
///
/// </summary>
/// <param name="edge"></param>
/// <param name="graphNode"></param>
public void AddGraphNode(Edge edge, int parentGraphNodeId, GraphNode graphNode)
{
GraphNode parent = GetGraphNodeById(parentGraphNodeId);
edge.StartGraphNodeId = parentGraphNodeId;
edge.EndGraphNodeId = graphNode.GraphNodeId;
EdgeCollection.Add(edge);
}
示例9: Margin
internal Margin(string otherControlName, Edge othersEdge, float distance)
: this()
{
OtherControlName = otherControlName;
OthersEdge = othersEdge;
Distance = distance;
}
示例10: NavigationTriangle
//public NavigationTriangle(Vector3 a, Vector3 b, Vector3 c)
public NavigationTriangle(Edge e1, Edge e2, Edge e3)
{
//m_neighbours[0] = null; // neighbour on a -> b side
//m_neighbours[1] = null; // neighbour on b -> c side
//m_neighbours[2] = null; // neighbour on c -> a side
m_edge1 = e1;
m_edge2 = e2;
m_edge3 = e3;
Vector3 a,b,c;
m_edge1.getCommonVertex(m_edge3, out a);
m_edge1.getCommonVertex(m_edge2, out b);
m_edge2.getCommonVertex(m_edge3, out c);
m_corners[0] = a;
m_corners[1] = b;
m_corners[2] = c;
m_dirs[0] = Vector3.Subtract(c, a);
m_dirs[1] = Vector3.Subtract(b, a);
m_normal = Vector3.Cross(m_dirs[0], m_dirs[1]);
m_normal.Normalize();
}
示例11: Bisect
internal static Edge Bisect(Site s1, Site s2)
{
var newEdge = new Edge();
newEdge.Sites[LR.Left] = s1;
newEdge.Sites[LR.Right] = s2;
newEdge.Vertices[LR.Left] = newEdge.Vertices[LR.Right] = null;
var dx = s2.Coord.X - s1.Coord.X;
var dy = s2.Coord.Y - s1.Coord.Y;
var adx = dx > 0 ? dx : -dx;
var ady = dy > 0 ? dy : -dy;
newEdge.C = s1.Coord.X*dx + s1.Coord.Y*dy + (dx*dx + dy*dy)*0.5f;
if (adx > ady) {
newEdge.A = 1.0f;
newEdge.B = dy/dx;
newEdge.C /= dx;
} else {
newEdge.B = 1.0f;
newEdge.A = dy/dx;
newEdge.C /= dy;
}
newEdge.EdgeID = NumEdges;
Out.Bisector(newEdge);
NumEdges++;
return newEdge;
}
示例12: CheckPredecessorLineGraph
public void CheckPredecessorLineGraph()
{
AdjacencyGraph<int, Edge<int>> g = new AdjacencyGraph<int, Edge<int>>(true);
g.AddVertex(1);
g.AddVertex(2);
g.AddVertex(3);
Edge<int> e12 = new Edge<int>(1, 2); g.AddEdge(e12);
Edge<int> e23 = new Edge<int>(2, 3); g.AddEdge(e23);
var dij = new DijkstraShortestPathAlgorithm<int, Edge<int>>(g, e => 1);
var vis = new VertexPredecessorRecorderObserver<int, Edge<int>>();
using(vis.Attach(dij))
dij.Compute(1);
IEnumerable<Edge<int>> path;
Assert.IsTrue(vis.TryGetPath(2, out path));
var col = path.ToList();
Assert.AreEqual(1, col.Count);
Assert.AreEqual(e12, col[0]);
Assert.IsTrue(vis.TryGetPath(3, out path));
col = path.ToList();
Assert.AreEqual(2, col.Count);
Assert.AreEqual(e12, col[0]);
Assert.AreEqual(e23, col[1]);
}
示例13: Main
static void Main(string[] args)
{
while (true)
{
s = Console.ReadLine();
if (s == null)
break;
inp = s.Split(sep, StringSplitOptions.RemoveEmptyEntries);
n = int.Parse(inp[0]);
m = int.Parse(inp[1]);
inp = Console.ReadLine().Split(sep, StringSplitOptions.RemoveEmptyEntries);
o = int.Parse(inp[0]) - 1;
d = int.Parse(inp[1]) - 1;
for (int i = 0; i < m; i++)
{
inp = Console.ReadLine().Split(sep, StringSplitOptions.RemoveEmptyEntries);
edges[i] = new Edge(int.Parse(inp[0]) - 1, int.Parse(inp[1]) - 1, double.Parse(inp[2]), double.Parse(inp[3]));
}
bellman_ford(o, n, m, -1);
double temp = data[0, d];
bellman_ford(o, n, m, temp);
LinkedList<int> path = Path(o, d);
LinkedListNode<int> aux = path.First;
while (aux != path.Last)
{
Console.Write(aux.Value + 1 + " ");
aux = aux.Next;
}
Console.WriteLine(aux.Value + 1);
Console.WriteLine("{0} {1}", data[0, d].ToString(".0"), temp.ToString(".0"));
}
}
示例14: maxFlow
static int maxFlow(List<Edge>[] graph, int s, int t)
{
int flow = 0;
int[] q = new int[graph.Count()];
while (true) {
int qt = 0;
q[qt++] = s;
Edge[] pred = new Edge[graph.Count() ];
for (int qh = 0; qh < qt && pred[t] == null; qh++) {
int cur = q[qh];
foreach(Edge e in graph[cur]) {
if (pred[e.t] == null && e.cap > e.f) {
pred[e.t] = e;
q[qt++] = e.t;
}
}
}
if (pred[t] == null)
break;
int df = int.MaxValue;
for (int u = t; u != s; u = pred[u].s)
df = Math.Min(df, pred[u].cap - pred[u].f);
for (int u = t; u != s; u = pred[u].s) {
pred[u].f += df;
graph[pred[u].t].ElementAt(pred[u].rev).f -= df;
}
flow += df;
}
return flow;
}
示例15: expandSide
public static void expandSide( ref Rectangle rect, Edge edge, int amount )
{
// ensure we have a positive value
amount = Math.Abs( amount );
switch( edge )
{
case Edge.Top:
rect.Y -= amount;
rect.Height += amount;
break;
case Edge.Bottom:
rect.Height += amount;
break;
case Edge.Left:
rect.X -= amount;
rect.Width += amount;
break;
case Edge.Right:
rect.Width += amount;
break;
default:
throw new ArgumentOutOfRangeException();
}
}