本文整理汇总了C#中Vertex类的典型用法代码示例。如果您正苦于以下问题:C# Vertex类的具体用法?C# Vertex怎么用?C# Vertex使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Vertex类属于命名空间,在下文中一共展示了Vertex类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1:
public Edge this[Vertex strartVertex, Vertex endVertex]
{
get
{
return this[strartVertex.Label, endVertex.Label];
}
}
开发者ID:JustMeGaaRa,项目名称:Silent.Algorithms,代码行数:7,代码来源:Graph.cs
示例2: ApplyVelocity
private void ApplyVelocity(ref Vertex position, ref Vertex velocity)
{
float newX = position.X + velocity.X;
if (newX < 0)
{
position.X = -newX;
velocity.X *= -1;
}
else if (newX > openGLControl1.ActualWidth)
{
position.X -= (newX - (float) openGLControl1.ActualWidth);
velocity.X *= -1;
}
else
{
position.X = newX;
}
float newy = position.Y + velocity.Y;
if (newy < 0)
{
position.Y = -newy;
velocity.Y *= -1;
}
else if (newy > openGLControl1.ActualHeight)
{
position.Y -= (newy - (float) openGLControl1.ActualHeight);
velocity.Y *= -1;
}
else
{
position.Y = newy;
}
}
开发者ID:hhool,项目名称:sharpgl,代码行数:35,代码来源:MainWindow.xaml.cs
示例3: VertexAndEdge
public void VertexAndEdge()
{
var graph = new Graph<int>(true);
var vertex1 = new Vertex<int>(3);
var vertex2 = new Vertex<int>(4);
var vertex3 = new Vertex<int>(5);
graph.AddVertex(vertex1);
graph.AddVertex(vertex2);
graph.AddVertex(vertex3);
graph.AddEdge(vertex2, vertex1);
vertex2 = SerializeUtil.BinarySerializeDeserialize(vertex1);
TestIsCopy(vertex1, vertex2);
Assert.AreEqual(vertex2.IncidentEdges.Count, 1);
Assert.AreEqual(vertex1.IncidentEdges.Count, 1);
Assert.AreEqual(vertex2.EmanatingEdges.Count, 0);
Assert.AreEqual(vertex1.EmanatingEdges.Count, 0);
TestIsCopy(vertex2.IncidentEdges[0], vertex1.IncidentEdges[0]);
}
开发者ID:GTuritto,项目名称:ngenerics,代码行数:28,代码来源:Serializable.cs
示例4: CutoffRiverPart
public void CutoffRiverPart(Direction direction)
{
int maxIndex = -1;
switch (direction)
{
case Direction.up:
for(int i=0;i<riverPath.Count;i++)
{
if(riverPath[i].z < 0)
{
maxIndex = i;
}
botVertex = riverPath[maxIndex + 1];
}
break;
case Direction.down:
for (int i = 0; i < riverPath.Count; i++)
{
if (riverPath[i].z > terrain.terrainSize)
{
maxIndex = i;
}
topVertex = riverPath[maxIndex + 1];
}
break;
}
for(int i = maxIndex; i >= 0; i--)
{
Debug.Log("cutting: " + riverPath[i]);
riverPath.RemoveAt(i);
}
}
开发者ID:ja003,项目名称:Fractal-Nature,代码行数:33,代码来源:RiverInfo.cs
示例5: SetRandomEdge
public static void SetRandomEdge(Vertex[] vertices)
{
bool found = false;
int i = 0;
int j = 0;
int count = 0;
Random random = new Random();
for (int k = 0; k < vertices.Length; k++)
{
for(int l = 0; l < vertices.Length; l++)
{
if (k == l || vertices[k].Vertices.Any(v => v == vertices[l]))
continue;
count++;
if(random.Next(0, count) == 0)
{
i = k;
j = l;
found = true;
}
}
}
if (found)
vertices[i].AddDirectedEdge(vertices[j]);
}
开发者ID:mmoroney,项目名称:Algorithms,代码行数:29,代码来源:GraphUtilities.cs
示例6: Simple
public void Simple()
{
var graph = new Graph<int>(false);
var vertices = new Vertex<int>[20];
for (var i = 0; i < 20; i++)
{
vertices[i] = new Vertex<int>(i);
graph.AddVertex(vertices[i]);
}
for (var i = 0; i < 17; i += 2)
{
var edge = new Edge<int>(vertices[i], vertices[i + 2], false);
graph.AddEdge(edge);
}
var trackingVisitor = new TrackingVisitor<int>();
graph.AcceptVisitor(trackingVisitor);
Assert.AreEqual(trackingVisitor.TrackingList.Count, 20);
for (var i = 0; i < 20; i++)
{
Assert.IsTrue(trackingVisitor.TrackingList.Contains(i));
}
}
开发者ID:havok,项目名称:ngenerics,代码行数:29,代码来源:Accept.cs
示例7: AddVertex
protected void AddVertex(Face face, Vertex vertex)
{
base.AddVertex(vertex);
Faces.Remove(face);
HalfEdge h1 = face.HalfEdge;
HalfEdge h2 = h1.Next;
HalfEdge h3 = h2.Next;
HalfEdge h4 = new HalfEdge(h1.Origin);
HalfEdge h5 = new HalfEdge(h2.Origin);
HalfEdge h6 = new HalfEdge(h3.Origin);
HalfEdge h7 = new HalfEdge(vertex);
HalfEdge h8 = new HalfEdge(vertex);
HalfEdge h9 = new HalfEdge(vertex);
HalfEdges.AddRange(new List<HalfEdge> {h4, h5, h6, h7, h8, h9});
h4.Twin = h7;
h7.Twin = h4;
h5.Twin = h8;
h8.Twin = h5;
h6.Twin = h9;
h9.Twin = h6;
// Set all next
h1.Next = h5;
h5.Prev = h1;
h5.Next = h7;
h7.Prev = h5;
h7.Next = h1;
h1.Prev = h7;
h2.Next = h6;
h6.Prev = h2;
h6.Next = h8;
h8.Prev = h6;
h8.Next = h2;
h2.Prev = h8;
h3.Next = h4;
h4.Prev = h3;
h4.Next = h9;
h9.Prev = h4;
h9.Next = h3;
h3.Prev = h9;
Triangle t1 = new Triangle(h1);
Triangle t2 = new Triangle(h2);
Triangle t3 = new Triangle(h3);
Faces.Add(t1);
Faces.Add(t2);
Faces.Add(t3);
Tree.Add(vertex, t1, t2, t3);
LogEntry logEntry = new LogEntry("Adding edges.", this);
logEntry.Objects.Add(vertex);
Log.Add(logEntry);
}
开发者ID:LuukvH,项目名称:Voronoi-Game,代码行数:60,代码来源:Triangulation.cs
示例8: DBPath
public DBPath(Vertex myStartVertex, Vertex myEndVertex, IEnumerable<Vertex> myVertices, IEnumerable<EdgeLabel> myEdges)
{
#region Initial Checks
if (myStartVertex == null)
throw new ArgumentNullException();
if (myEndVertex == null)
throw new ArgumentNullException();
if (myVertices == null)
throw new ArgumentNullException();
if (myEdges == null)
throw new ArgumentNullException();
if (myVertices.Count() != myEdges.Count() - 1)
throw new ArgumentException();
#endregion
StartVertex = myStartVertex;
EndVertex = myEndVertex;
Vertices = myVertices;
Edges = myEdges;
Length = (UInt64) myEdges.LongCount();
}
开发者ID:ipbi,项目名称:sones,代码行数:27,代码来源:DBPath.cs
示例9: collapse
/**
* collapse vertex u to vertex v
*/
private void collapse(Vertex u, Vertex v)
{
// remove the adjacent face of both vertex u and vertex v
for (int i = 0; i < u.adjacent_faces.Count; ++i) {
if (u.adjacent_faces[i].has(v)) {
for (int j = 0; j < 3; ++j) {
Vertex v_temp = u.adjacent_faces[i].triangle_vertices[j];
if (!v_temp.Equals(u)) {
for (int k = 0; k < v_temp.adjacent_faces.Count; ++k) {
if (v_temp.adjacent_faces[k].Equals(u.adjacent_faces[i])) {
v_temp.adjacent_faces.RemoveAt(k);
break;
}
}
}
}
u.adjacent_faces.RemoveAt(i);
--i;
}
}
// replace vertex u with vertex v in adjacent faces of neighbor vertices of vertex u
for (int i = 0, i_count = u.neighbor_vertices.Count; i < i_count; ++i) {
Vertex v_temp = u.neighbor_vertices[i];
for (int j = 0, j_count = v_temp.adjacent_faces.Count; j < j_count; ++j) {
if (v_temp.adjacent_faces[j].has(u)) {
v_temp.adjacent_faces[j].replaceVertex(u, v);
}
}
}
// replace vertex u with vertex v in adjacent faces of vertex u
for (int i = 0, count = u.adjacent_faces.Count; i < count; ++i) {
u.adjacent_faces[i].replaceVertex(u, v);
}
// remove vertex u
vertices.RemoveAt(vertices.IndexOf(u));
// remove vertex u in neighbor vertices of vertex u
// add neighbor vertices of vertex u to vertex v
// add vertex v to neighbor vertices of vertex u
// update collapse cost at neighbor vertices of vertex u
for (int i = 0, count = u.neighbor_vertices.Count; i < count; ++i) {
u.neighbor_vertices[i].neighbor_vertices.Remove(u);
if (!u.neighbor_vertices[i].Equals(v)) {
v.neighbor_vertices.Add(u.neighbor_vertices[i]);
u.neighbor_vertices[i].neighbor_vertices.Add(v);
distinct(u.neighbor_vertices[i].neighbor_vertices);
}
computeEdgeCollapseCostAtVertex(u.neighbor_vertices[i]);
}
distinct(v.neighbor_vertices);
// add new faces to vertex v and update collapse cost of vertex v
for (int i = 0, count = u.adjacent_faces.Count; i < count; ++i) {
v.adjacent_faces.Add(u.adjacent_faces[i]);
}
computeEdgeCollapseCostAtVertex(v);
}
开发者ID:FlyTeeth1128,项目名称:GDGeek,代码行数:63,代码来源:VoxelRemoveFace.cs
示例10: VoronoiRegion
public VoronoiRegion(Vertex generator)
{
this.id = generator.id;
this.generator = generator;
this.vertices = new List<Point>();
this.bounded = true;
}
开发者ID:JackTing,项目名称:PathCAM,代码行数:7,代码来源:VoronoiRegion.cs
示例11: ReplaceVertex
//this face is one of the srrounding faces attahed to vold
public void ReplaceVertex(Vertex vold,Vertex vnew)
{
for(int i = 0; i < 3; i++)
{
if(vertex[i].position == vold.position )
{
vertex[i] = vnew;
vold.RemoveFace( this );
if(vnew!=null)
vnew.AddFace( this );
break;
}
}
//remove reff of vold from Neighborhood
vold.RemoveIfNonNeighbor( vertex[0] );
vertex[0].RemoveIfNonNeighbor( vold );
vold.RemoveIfNonNeighbor( vertex[1] );
vertex[1].RemoveIfNonNeighbor( vold );
vold.RemoveIfNonNeighbor( vertex[2] );
vertex[2].RemoveIfNonNeighbor( vold );
vertex[0]. AddNeighbor(vertex[1]);
vertex[0]. AddNeighbor(vertex[2]);
vertex[1]. AddNeighbor(vertex[0]);
vertex[1]. AddNeighbor(vertex[2]);
vertex[2]. AddNeighbor(vertex[0]);
vertex[2]. AddNeighbor(vertex[1]);
ComputeNormal();
}
开发者ID:Gh0stBlade,项目名称:TR2-Level-Viewer,代码行数:35,代码来源:Triangle.cs
示例12: DirectedValue
public void DirectedValue()
{
var graph = new Graph<int>(true);
var vertex1 = new Vertex<int>(1);
var vertex2 = new Vertex<int>(2);
var vertex3 = new Vertex<int>(3);
graph.AddVertex(vertex1);
graph.AddVertex(vertex2);
graph.AddVertex(vertex3);
graph.AddEdge(vertex1, vertex2);
graph.AddEdge(vertex3, vertex2);
graph.AddEdge(vertex1, vertex3);
Assert.AreEqual(graph.Edges.Count, 3);
Assert.AreEqual(graph.Vertices.Count, 3);
Assert.IsTrue(graph.RemoveVertex(1));
Assert.AreEqual(graph.Edges.Count, 1);
Assert.AreEqual(graph.Vertices.Count, 2);
Assert.IsFalse(graph.RemoveVertex(4));
Assert.AreEqual(graph.Edges.Count, 1);
Assert.AreEqual(graph.Vertices.Count, 2);
}
开发者ID:havok,项目名称:ngenerics,代码行数:27,代码来源:RemoveVertex.cs
示例13: Update
// Update is called once per frame
void Update()
{
// Move towards current target
if(currentDestination != null && pos != currentDestination){
if(!rm.Moving){
pos = next_node;
if(!occupying){
FindTarget();
}
List<Vertex> p = rf.FindPath(pos, currentDestination, wg.GetPathfindingCosts());
if(p != null && p.Count > 1){
next_node = p[1];
rm.Move(wg.VertexToVector3(next_node));
} else {
currentDestination = pos;
}
}
} else if(currentDestination != null && target != null && pos == currentDestination && !occupying){
target = wl.OccupyBurrow(pos);
if(target != null){
occupying = true;
}
} else {
if(!occupying){
FindTarget();
}else{
UpdateTarget();
}
}
}
开发者ID:9volt,项目名称:ld29,代码行数:31,代码来源:Ferret.cs
示例14: SynchronousSearch
public TraveledPathData SynchronousSearch(Graph graph, Vertex root, Vertex goal)
{
this.graph = graph;
this.root = root;
this.goal = goal;
return this.SyncSearch();
}
开发者ID:DVitinnik,项目名称:UniversityApps,代码行数:7,代码来源:GreedySearch.cs
示例15: Undirected
public void Undirected()
{
var graph = new Graph<int>(false);
var vertex1 = new Vertex<int>(1);
var vertex2 = new Vertex<int>(2);
var vertex3 = new Vertex<int>(3);
var vertex4 = new Vertex<int>(4);
graph.AddVertex(vertex1);
graph.AddVertex(vertex2);
graph.AddVertex(vertex3);
graph.AddVertex(vertex4);
graph.AddEdge(vertex1, vertex2);
graph.AddEdge(vertex3, vertex2);
graph.AddEdge(vertex1, vertex3);
Assert.IsFalse(graph.IsStronglyConnected());
graph.AddEdge(vertex2, vertex4);
Assert.IsTrue(graph.IsStronglyConnected());
graph.RemoveEdge(vertex2, vertex3);
Assert.IsTrue(graph.IsStronglyConnected());
graph.RemoveEdge(vertex1, vertex3);
Assert.IsFalse(graph.IsStronglyConnected());
}
开发者ID:GTuritto,项目名称:ngenerics,代码行数:31,代码来源:IsStronglyConnected.cs
示例16: AsynchronousSearch
public override void AsynchronousSearch(Graph graph, Vertex root, Vertex goal)
{
this.graph = graph;
this.root = root;
this.goal = goal;
new Thread(AsyncSearch).Start();
}
开发者ID:DVitinnik,项目名称:UniversityApps,代码行数:7,代码来源:GreedySearch.cs
示例17: GetImplications
public List<Implication> GetImplications(Vertex leaf, int nextTime)
{
var triggeredActions = this.GetTriggeredActions(leaf.ActualWorldAction, leaf.ActualState, leaf.Time);
var possibleFutureStates = this.GetPossibleFutureStates(leaf.ActualWorldAction, leaf.ActualState, leaf.Time);
return possibleFutureStates.Select(possibleFutureState =>
new Implication { FutureState = possibleFutureState, TriggeredActions = triggeredActions.ToList() }).ToList();
}
开发者ID:upstreamfall,项目名称:knowledgerepresentation,代码行数:7,代码来源:WorldDescription.cs
示例18: Rung4
public static Vertex Rung4(GraphData d)
{
Vertex v = new Vertex();
v.Include = Root + "Rung4.html";
Edge e;
string NextVertexName = "TraditionalCrises_Rung5";
e = new Edge(d);
e.State.VertexName = NextVertexName;
//e.State.Stakes += 5;
e.HTML = "A public and irrevocable increase in the stakes";
v.Edges.Add(e);
e = new Edge(d);
e.State.VertexName = NextVertexName;
//e.State.PublicAwareness += 20;
e.HTML = "Officially inspire newspaper stories to the effect that the chief of state takes a serious view of the matter.";
v.Edges.Add(e);
return v;
}
开发者ID:Baloogan,项目名称:Escalation,代码行数:26,代码来源:TraditionalCrises.cs
示例19: TestEquatable
public void TestEquatable()
{
var vn = new Vertex(12.34f, -98.7f, 54);
var vertices = new Vertex[] { new Vertex(), vn, new Vertex(3, 2, 1) };
var facet = new Facet(vn, vertices);
IEquatable<Facet> ieqFacet = facet;
Assert.False(ieqFacet.Equals((Facet)null));
var facet2 = new Facet();
Assert.False(ieqFacet.Equals(facet2));
facet2 = new Facet(new Vertex(12.34f, -98.7f, 54), null);
Assert.False(ieqFacet.Equals(facet2));
facet2 = new Facet() { Normal = null };
Assert.False(ieqFacet.Equals(facet2));
facet2 = new Facet() { Vertices = null };
Assert.False(ieqFacet.Equals(facet2));
facet2 = new Facet(new Vertex(12.34f, -98.7f, 54), vertices);
Assert.True(ieqFacet.Equals(facet2));
Assert.True(ieqFacet.Equals(facet));
}
开发者ID:frenchmakers,项目名称:StlLibSharp,代码行数:27,代码来源:FacetTest.cs
示例20: DepthFirstSearch
public Dictionary<Vertex, DFSVisitingInfo> DepthFirstSearch(Vertex v)
{
var visits = new Dictionary<Vertex, DFSVisitingInfo>();
visits[v] = new DFSVisitingInfo(null);
DepthFirstSearch(v, visits);
return visits;
}
开发者ID:OlegDudnyk,项目名称:NGraphs,代码行数:7,代码来源:Graph.cs
注:本文中的Vertex类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论