The GeneralVertexList object represents an indexed list of vertices which may be anything, and is often used in conjection with either SparseGraph, PySparseGraph or DenseGraph. The following example demonstrates its usage:

from apgl.graph import *
import numpy

numVertices = 10
numFeatures = 3

vList = GeneralVertexList(numVertices)
vList.setVertex(0, "abc")
vList.setVertex(1, "def")

This code creates a GeneralVertexList object, and assigns strings to the first and second vertices.


class apgl.graph.GeneralVertexList.GeneralVertexList(numVertices)

Bases: apgl.graph.AbstractVertexList.AbstractVertexList

Create an empty GeneralVertexList with the specified number of features for each vertex (initialised as None) and number of vertices.

Parameters:numVertices (int) – The number of vertices.
V = None

Adds n vertices to this object.


Sets a vertex to None

Parameters:index (int) – the index of the vertex to assign a value.

Returns a copy of this object.

ext = '.gvl'

Returns the number of vertices contained in this object.


Returns the value of a vertex.

Parameters:index (int) – the index of the vertex.

Returns a list of vertices specified by vertexIndices, or all vertices if vertexIndices == None.

Parameters:vertexIndices (list) – a list of vertex indices.
Returns:A set of vertices corresponding to the input indices.
static load(filename)

Load this object from filename.pkl.

Parameters:filename (str) – The name of the file to load.

Save this object to filename.nvl.

Parameters:filename (str) – The name of the file to save to.
Returns:The name of the saved file including extension.
setVertex(index, value)

Set a vertex to the corresponding value.

  • index (int) – the index of the vertex to assign a value.
  • value – the value to assign to the vertex.
setVertices(vertices, indices=None)

Set the vertices to the given list of vertices. If indices = None then all vertices are replaced, and if not the given indices are used.

  • vertices (list) – a list of vertices..
  • indices (list) – a list of indices of the same length as vertices or None for all indices in this object.

Returns a subset of this object, indicated by the given indices.

Table Of Contents

Previous topic


Next topic


This Page