public class

HashBasedHipsterGraph

extends Object
implements HipsterMutableGraph<V, E>
java.lang.Object
   ↳ es.usc.citius.hipster.graph.HashBasedHipsterGraph<V, E>
Known Direct Subclasses

Class Overview

Lightweight implementation of an in-memory, mutable graph backed to a HashMap where keys are vertices and edges are GraphEdges

Summary

Fields
protected HashMap<V, Set<GraphEdge<V, E>>> connected
Public Constructors
HashBasedHipsterGraph()
Public Methods
boolean add(V v)
Adds a new vertex to the graph.
Set<V> add(V... vertices)
Adds multiple vertices to the graph.
GraphEdge<V, E> buildEdge(V v1, V v2, E value)
GraphEdge<V, E> connect(V v1, V v2, E value)
Connects to vertices of the graph through an edge
static <V, E> HashBasedHipsterGraph<V, E> create()
Iterable<GraphEdge<V, E>> edges()
Returns a list of the edges in the graph.
Iterable<GraphEdge<V, E>> edgesOf(V vertex)
Return all the edges that are connected with the given vertex.
HashMap<V, Set<GraphEdge<V, E>>> getConnected()
Returns the internal HashMap representation of the graph
Set<V> remove(V... vertices)
Removes multiple vertices from the graph
boolean remove(V v)
Removes the vertex from the graph
void setConnected(HashMap<V, Set<GraphEdge<V, E>>> connected)
Iterable<V> vertices()
Returns the vertices of the graph.
Protected Methods
Iterable<Entry<V, GraphEdge<V, E>>> vedges()
[Expand]
Inherited Methods
From class java.lang.Object
From interface es.usc.citius.hipster.graph.HipsterGraph
From interface es.usc.citius.hipster.graph.HipsterMutableGraph

Fields

protected HashMap<V, Set<GraphEdge<V, E>>> connected

Public Constructors

public HashBasedHipsterGraph ()

Public Methods

public boolean add (V v)

Adds a new vertex to the graph.

Parameters
v vertex to be added
Returns
  • true if the vertex was added to the graph, false if the vertex is already present

public Set<V> add (V... vertices)

Adds multiple vertices to the graph.

Parameters
vertices vertices to be added
Returns
  • set with the vertices added

public GraphEdge<V, E> buildEdge (V v1, V v2, E value)

public GraphEdge<V, E> connect (V v1, V v2, E value)

Connects to vertices of the graph through an edge

Parameters
v1 source vertex
v2 target (destination) vertex
value value of the edge connecting vertex1 and vertex2
Returns

public static HashBasedHipsterGraph<V, E> create ()

public Iterable<GraphEdge<V, E>> edges ()

Returns a list of the edges in the graph.

Returns
  • edges of the graph.

public Iterable<GraphEdge<V, E>> edgesOf (V vertex)

Return all the edges that are connected with the given vertex.

Parameters
vertex vertex to be queried
Returns
  • an iterable of GraphEdges connected to the vertex

public HashMap<V, Set<GraphEdge<V, E>>> getConnected ()

Returns the internal HashMap representation of the graph

Returns
  • HashMap where keys are vertices and values a set with the connected edges

public Set<V> remove (V... vertices)

Removes multiple vertices from the graph

Parameters
vertices vertices to be removed
Returns
  • set of vertices removed from the graph

public boolean remove (V v)

Removes the vertex from the graph

Parameters
v vertex to be removed
Returns
  • true if the vertex was removed, false if the vertex is not present

public void setConnected (HashMap<V, Set<GraphEdge<V, E>>> connected)

public Iterable<V> vertices ()

Returns the vertices of the graph. Any changes in the returned iterator affect the underlying graph structure.

Returns
  • iterator with the vertices of the graph

Protected Methods

protected Iterable<Entry<V, GraphEdge<V, E>>> vedges ()