Module: GRATR::GraphAPI

Included in:
Graph
Defined in:
lib/gratr/graph_api.rb

Overview

This defines the minimum set of functions required to make a graph class that can use the algorithms defined by this library

Instance Method Summary collapse

Instance Method Details

#add_edge!(u, v = nil, l = nil) ⇒ Object

Add an edge to the Graph and return the Graph u can be an object of type GRATR::Arc or u,v specifies a source, target pair. The last parameter is an optional label

This method must be implemented by the specific graph class

Raises:

  • (NotImplementedError)


51
# File 'lib/gratr/graph_api.rb', line 51

def add_edge!(u,v=nil,l=nil) raise NotImplementedError; end

#add_vertex!(v, l = nil) ⇒ Object

Add a vertex to the Graph and return the Graph An additional label l can be specified as well

This method must be implemented by the specific graph class

Raises:

  • (NotImplementedError)


44
# File 'lib/gratr/graph_api.rb', line 44

def add_vertex!(v,l=nil)     raise NotImplementedError; end

#chromatic_numberObject

Return the chromatic number for this graph This is currently incomplete and in some cases will be NP-complete FIXME: Should this even be here? My gut feeling is no…

Raises:

  • (NotImplementedError)


80
# File 'lib/gratr/graph_api.rb', line 80

def chromatic_number()      raise NotImplementedError; end

#directed?Boolean

Is the graph directed?

This method must be implemented by the specific graph class

Raises:

  • (NotImplementedError)


38
# File 'lib/gratr/graph_api.rb', line 38

def directed?()             raise NotImplementedError; end

#edge_classObject

Returns the edge class

Raises:

  • (NotImplementedError)


75
# File 'lib/gratr/graph_api.rb', line 75

def edge_class()            raise NotImplementedError; end

#edgesObject

Return the array of edges.

This method must be implemented by the specific graph class

Raises:

  • (NotImplementedError)


72
# File 'lib/gratr/graph_api.rb', line 72

def edges()                 raise NotImplementedError; end

#remove_edge!(u, v = nil) ⇒ Object

Remove an edge from the Graph and return the Graph

Can be a type of GRATR::Arc or a source and target This method must be implemented by the specific graph class

Raises:

  • (NotImplementedError)


62
# File 'lib/gratr/graph_api.rb', line 62

def remove_edge!(u,v=nil)    raise NotImplementedError; end

#remove_vertex!(v) ⇒ Object

Remove a vertex to the Graph and return the Graph

This method must be implemented by the specific graph class

Raises:

  • (NotImplementedError)


56
# File 'lib/gratr/graph_api.rb', line 56

def remove_vertex!(v)        raise NotImplementedError; end

#verticesObject

Return the array of vertices.

This method must be implemented by the specific graph class

Raises:

  • (NotImplementedError)


67
# File 'lib/gratr/graph_api.rb', line 67

def vertices()              raise NotImplementedError; end