public bool insertEdge(Object edgeInfo, Vertex vertexPtr) { if (!this.isAdjacent(vertexPtr)) { Edge edge = new Edge(edgeInfo, vertexPtr); EdgeList.Add(edge); return true; } return false; }
public bool isAdjacent(Vertex vertex) { foreach (Edge found in this.EdgeList) { if (found.Vertex != null) { if (found.Vertex.Equals(vertex)) return true; } } return false; }
public bool deleteEdge(Vertex vertex) { foreach (Edge theEdge in EdgeList) { if (theEdge.Vertex.Equals(vertex)) { EdgeList.Remove(theEdge); return true; } } return false; }
public bool deleteEdge(Vertex ptailVertex, Vertex pheadVertex) { return ptailVertex.deleteEdge(pheadVertex); }
public int degree(Vertex pVertex) { return inDegree(pVertex) + outDegree(pVertex); }
public bool areAdjacents(Vertex ptailVertex, Vertex pheadVertex) { return ptailVertex.isAdjacent(pheadVertex); }
/// <summary> /// Adds a vertex to the graph /// </summary> /// <param name="pVertexKey"> Vertex key</param> /// <param name="pInfo"> Object containing vertex information</param> public void addVertex(String pVertexKey, Object pInfo) { Vertex vert = new Vertex(pVertexKey, pInfo); this.verticesList.Add(vert); }
/// <summary> /// Adds an arc between two vertexs /// </summary> /// <param name="pEdgeInfo"> Object containing edge information</param> /// <param name="ptailVertex"> Vertex from where the arc</param> /// <param name="pheadVertex"> Vertex where the arc ends</param> public bool addEdge(Object pEdgeInfo, Vertex ptailVertex, Vertex pheadVertex) { return ptailVertex.insertEdge(pEdgeInfo, pheadVertex); }
public int outDegree(Vertex pVertex) { return pVertex.EdgeList.Count; }
public int inDegree(Vertex pVertex) { int inDegree = 0; foreach (Vertex theVertex in VerticesList) { if (theVertex.isAdjacent(pVertex)) inDegree++; } return inDegree; }
public List<Vertex> getInAdjacentsVertexs(Vertex pVertex) { List<Vertex> adjList = new List<Vertex>(); foreach (Vertex theVertex in this.VerticesList) { if (theVertex.isAdjacent(pVertex)) adjList.Add(theVertex); } return adjList; }
public List<Edge> getInAdjacentsEdges(Vertex pVertex) { List<Edge> adjList = new List<Edge>(); foreach (Vertex theVertex in this.VerticesList) { if (theVertex.isAdjacent(pVertex)) adjList.Add(theVertex.EdgeList.Where(e => e.Vertex.Key == pVertex.Key).FirstOrDefault()); } return adjList; }
public List<Vertex> getAdjacentsVertexs(Vertex pVertex) { List<Vertex> adjList = new List<Vertex>(); foreach (Edge adjEdge in pVertex.EdgeList) adjList.Add(adjEdge.Vertex); return adjList; }
public bool deleteVertexWithEdges(Vertex pVertex) { foreach (Vertex delVertex in this.VerticesList) { if (delVertex.isAdjacent(pVertex)) delVertex.deleteEdge(pVertex); } return true; }
public bool deleteVertex(Vertex pVertex) { foreach (Vertex delVertex in this.VerticesList) { if (delVertex.Equals(pVertex)) { pVertex.deleteAllEdges(); this.VerticesList.Remove(pVertex); return true; } } return false; }
public Edge(Object info, Vertex vertex) { this.Vertex = vertex; this.Info = info; }