1''' 2 3 4Created on 03 Feb 2010 5 6@author: charanpal 7''' 8 9from apgl.util.Util import Util 10from apgl.graph.AbstractGraph import AbstractGraph 11 12class AbstractMultiGraph(object): 13 """ 14 A very basic abstract base class for multi-graphs. Each edge has an index so that it 15 can be referred to. 16 """ 17 def addEdge(self, vertexIndex1, vertexIndex2, edgeTypeIndex, edge): 18 """ 19 Add an edge to the graph between two vertices. 20 21 @param vertexIndex1: The index of the first vertex. 22 @param vertexIndex1: The index of the second vertex. 23 @param edge: The value to assign to the edge. 24 """ 25 26 Util.abstract() 27 28 def removeEdge(self, vertexIndex1, vertexIndex2, edgeTypeIndex): 29 """ 30 Remove an edge between two vertices. 31 32 @param vertexIndex1: The index of the first vertex. 33 @param vertexIndex1: The index of the second vertex. 34 """ 35 Util.abstract() 36 37 def getNumEdges(self): 38 """ Returns the total number of edges in the graph. """ 39 Util.abstract() 40 41 def getNumVertices(self): 42 """ Returns the total number of vertices in the graph. """ 43 Util.abstract() 44 45 def isUndirected(self): 46 """ Returns true if the current graph is undirected, otherwise false. """ 47 Util.abstract() 48 49 50 def neighbours(self, vertexIndex1): 51 """ Return a iterable item of neighbours (indices) """ 52 Util.abstract() 53 54 def getNeighboursByEdgeType(self, vertexIndex1, edgeTypeIndex): 55 """ Return a iterable item of neighbours (indices) """ 56 Util.abstract() 57 58 def getEdge(self, vertexIndex1, vertexIndex2, edgeTypeIndex): 59 """ Return an edge between two vertices """ 60 Util.abstract() 61 62 def getVertex(self, vertexIndex): 63 """ Return a vertex of given index """ 64 Parameter.checkIndex(vertexIndex, 0, self.vList.getNumVertices()) 65 return self.vList.getVertex(vertexIndex) 66 67 def getAllVertexIds(self): 68 """ Return all indices of the vertices """ 69 Util.abstract() 70 71 def setVertex(self, vertexIndex, vertex): 72 """ Assign a value to a vertex """ 73 Util.abstract() 74 75 def getAllEdges(self): 76 """ 77 Return an array of edges with each row representing an edge and its type index. 78 """ 79 Util.abstract() 80