Skip to content
suharshs edited this page Apr 12, 2013 · 10 revisions

Everything in the giraph library is scoped under giraph but member function of instantiated graph objects are applied directly.

graph - create graph objects.

giraph . graph . graph()

Returns an empty instantiated undirected graph.

giraph . graph . digraph()

Returns an empty instantiated directed graph.

graph objects - manipulate graphs.

Let g be an instantiated graph or digraph object.

g . add_vertex( id[, weight[, extra]] )

Adds a vertex with id, weight, and user-defined extra information. Returns g.

g . add_edge( startvertex, endvertex[, weight[, extra]] )

Adds a edge with startvertex, endvertex, weight, and user-defined extra information. startvertex and endvertex must be valid vertices in g. Returns g.

g . remove_edge( startvertex, endvertex )

Removes a edge with endpoints startvertex and endvertex, weight_. startvertex and endvertex must be valid vertices in g. Returns g. Returns false if unsuccessful.

g . remove_vertex( vertexid )

Removes the vertex in g with vertexid. Returns g. Returns false if unsuccessful.

g . vertex( vertexid )

Returns the vertex object in g with vertexid. vertexid must be a valid vertex in g. Returns false if unsuccessful.

g . edge( startvertex, endvertex )

Returns the edge object in g with endpoints startvertex and endvertex. startvertex and endvertex must be valid vertices in g. Returns false if unsuccessful.

g . size()

Returns the number of edges in g.

g . order()

Returns the number of vertices in g.

g . vertices( [sortfunction] )

Returns an array of vertex objects optionally sorted based on sortfunction. sortfunction takes two vertex objects as its parameters and returns a positive number if they should be swapped.

g . edges( [sortfunction] )

Returns an array edge objects optionally sorted based on sortfunction. sortfunction takes two vertex objects as its parameters and returns a positive number if they should be swapped.

graph components - vertices and edges

vertex object

Let v be a vertex object.

v . in_neighbors()

Returns the vertex ids for all of vertices that have an directed edge to v.

v . neighbors()

Returns the vertex ids for all of vertices v has an out-edge to. In the case of an undirected graph, returns the vertex ids for all vertices v shares an edge with.

v . id()

Returns the id of v.

v . weight( [weight] )

If no argument is provided, returns the weight of the vertex. If weight is passed, then sets the weight of the vertex to weight.

v . extra( [extra] )

If no argument is provided, returns the user-defined extra information of the vertex. If extra is passed, then sets the extra information of the vertex to extra.

v . is_neighbor( vertexid )

Returns true if the vertex with id vertexid is a neighbor of v. In the case of a directed graph returns true if the vertex with id vertexid is a out neighbor of v.

v . is_in_neighbor( v )

Returns true if the vertex with id vertexid has a directed edge pointing to v.

v . color( [rgbaString] )

If a rgbaString is passed then sets the color of this vertex to rgbaString when visualized. Otherwise, returns the current color of the vertex.

v . position( [x, y] )

If x and y are passed then sets the position of this vertex to x,y when visualized. Otherwise, returns an array of the current position of the vertex.

edge object

Let e be an edge object

e . id()

Returns the id of e.

e . weight( [weight] )

If no argument is provided, returns the weight of the edge. If weight is passed, then sets the weight of the edge to weight.

e . extra( [extra] )

If no argument is provided, returns the user-defined extra information of the edge. If extra is passed, then sets the extra information of the edge to extra.

e . endpoints()

Returns a list of size two containing the ids of the endpoint vertices of e. The first id is the startpoint and the second id is the endpoint.

e . color( rgbaString )

If a rgbaString is passed then sets the color of this edge to rgbaString when visualized. Otherwise, returns the current color of the edge.

alg - library algorithms

alg . kruskalMST ( graph )

Returns {MST: listOfEdges, weight: MSTweight} based on the MST of graph computed by Kruskal's algorithm.

alg . search ( graph, orderingStructure, startvertexid, targetid_ )

Returns {vertex: targetVertex, order: listOfVerticesInOrder} based on the search defined by the user input orderingStructure. The orderingStructure must have add, remove, size, and exists functions defined. Returns false if the target vertex is unreachable.

alg. BFS ( graph, startvertexid, targetid )

Returns {vertex: targetVertex, order: listOfVerticesInOrder} based on the BFS. Returns false if the target vertex is unreachable.

alg. DFS ( graph, startvertexid, targetid )

Returns {vertex: targetVertex, order: listOfVerticesInOrder} based on the DFS. Returns false if the target vertex is unreachable.