nz.ac.waikato.mcennis.rat.graph
Interface Graph

All Superinterfaces:
Model, ParsedObject, java.io.Serializable
All Known Implementing Classes:
Clique, DerbyGraph, MemGraph, NullGraph, PostgresqlGraph, Tree, UserIDList, UserList

public interface Graph
extends java.io.Serializable, ParsedObject, Model

Interface representing a social network. Users are the individuals consuming music, artists are the artists producing music, userlinks are the links between users (with some name or class attached to them), artistlinks are the links between users and artists, and similar artists are the links between different artists.


Method Summary
 void add(Actor u)
          Add a user to the graph.
 void add(Graph g)
          Add a graph (g) to the graph.
 void add(Link link)
          Adds a userlink to the graph.
 void add(PathSet pathSet)
          Add a PathSet to this graph.
 void add(Property prop)
          Add a property to this graph.
 void addChild(Graph g)
          Set the given graph to be a child of the current graph.
 void anonymize()
          Replaces all actor IDs with an anonymous numeric ID.
 void close()
          Close database connections or write to file.
 void commit()
          Commit the contents to database or storage.
 Actor[] getActor()
          Retrieve an array of all actors of all types.
 Actor[] getActor(java.lang.String type)
          Retrieve an array of all actors of a given type.
 Actor getActor(java.lang.String type, java.lang.String ID)
          Retrieve the users that has the given ID.
 int getActorCount(java.lang.String mode)
          Returns the number of actors of the given type
 java.util.Iterator<Actor> getActorIterator(java.lang.String type)
          Create a read only iterator over all actors.
 java.lang.String[] getActorTypes()
          List all types - returns null if no actors exist.
 Graph[] getChildren()
          Returns the children graphs of this object or null if none exist
 Graph getChildren(java.lang.String id)
          Returns the children graph with the given id or null if there is not a child with that name.
 Graph[] getGraphs(java.util.regex.Pattern pattern)
          Creates an array of graph objects.
 java.lang.String getID()
          Return the ID associated with this Graph
 Link[] getLink()
          Return all user to user links in this graph in an array.
 Link[] getLink(java.lang.String type)
          Retrieve an array of all userlinks of the given type from this graph or null if no such links are in this graph.
 Link[] getLink(java.lang.String type, Actor sourceActor, Actor destActor)
          Returns all links of the given type (relation) type going from actor sourceActor to actor destActor or null.
 Link[] getLinkByDestination(java.lang.String type, Actor destActor)
          Returns all links (edges, arcs) of type (relation) type that point to the given actor.
 Link[] getLinkBySource(java.lang.String type, Actor sourceActor)
          Returns all links (edges, arcs) of type (relation) type that go from the given actor to any destination.
 java.lang.String[] getLinkTypes()
          Returns all link types currently in this graph or null if no links are present.
 Parameter[] getParameters()
          Obtain a computer-readable description of the parameters and options this graph supports
 Graph getParent()
          Returns the parent graph of this object or null if this is a root graph
 PathSet[] getPathSet()
          Return all PathSets associated with this graph.
 PathSet getPathSet(java.lang.String id)
          Return the named PathSet.
 Property[] getProperty()
          Returns an array of all properties associated with this object or null if none exist
 Property getProperty(java.lang.String type)
          Return a property named by the given string or null if no property by this name exists
 Graph getSubGraph(java.util.Properties props, java.util.Set<Actor> actor)
          Creates a new graph from the current graph using the Properties props containing the actors actor and all links that link between actors in actor.
 Graph[] getSubGraph(Query q)
          Return newly created subgraphs that matches the given query FIXME: Currently not implemented in any graph.
 void init(java.util.Properties props)
          Set the parameters of this graph from the following property object.
 void remove(Actor u)
          Identifies the given user and removes it and all links involving it from the graph.
 void remove(Link ul)
          remove all user links with the same type, user ID, and artist ID from the graph
 void setID(java.lang.String id)
          Set this graph's ID to this value.
 void setSubGraph(Query q)
          Same as getSubGraph but the resulting graphs are stored internally NOTE: this interface may be removed.
 
Methods inherited from interface nz.ac.waikato.mcennis.rat.graph.model.Model
addListener
 

Method Detail

add

void add(Actor u)
Add a user to the graph. This replaces the user if a user with the same ID already exists.

Parameters:
u - user to be included in the graph.

add

void add(Link link)
Adds a userlink to the graph. There is no limit on the number of links between users or even with the same type, source user, and destination user.

Parameters:
link - description of a named link between two users

remove

void remove(Actor u)
Identifies the given user and removes it and all links involving it from the graph.

Parameters:
u - user to be removed from the graph.

remove

void remove(Link ul)
remove all user links with the same type, user ID, and artist ID from the graph

Parameters:
ul - link to be removed from the graph.

getActor

Actor getActor(java.lang.String type,
               java.lang.String ID)
Retrieve the users that has the given ID. Returns null if no user is in the graph with that ID.

Parameters:
type -
ID - ID string identifying an user
Returns:
user object who has this ID or null if it is not present

getActor

Actor[] getActor()
Retrieve an array of all actors of all types. Returns null if no actors are in the graph.

Returns:
array of all users in the graph

getActor

Actor[] getActor(java.lang.String type)
Retrieve an array of all actors of a given type. Returns null if there are no actors of that type in the graph.

Parameters:
type - class of actor to return
Returns:
array of actors of the given type

getActorIterator

java.util.Iterator<Actor> getActorIterator(java.lang.String type)
Create a read only iterator over all actors.

Parameters:
type - type (mode) of actor to return
Returns:
iterator over all actors of the given type

getActorTypes

java.lang.String[] getActorTypes()
List all types - returns null if no actors exist.

Returns:
array of all type names in this graph

getLink

Link[] getLink()
Return all user to user links in this graph in an array. Returns null if no such user link exists.

Returns:
array of all userlinks or null

getLink

Link[] getLink(java.lang.String type)
Retrieve an array of all userlinks of the given type from this graph or null if no such links are in this graph.

Parameters:
type -
Returns:
array of all user links of a given type or null

getLinkBySource

Link[] getLinkBySource(java.lang.String type,
                       Actor sourceActor)
Returns all links (edges, arcs) of type (relation) type that go from the given actor to any destination. Returns null if no such links exist.

Parameters:
type - type (relation) of link to return
sourceActor - starting point of the link
Returns:
Array of links or null

getLinkByDestination

Link[] getLinkByDestination(java.lang.String type,
                            Actor destActor)
Returns all links (edges, arcs) of type (relation) type that point to the given actor. Returns null if no such links exist

Parameters:
type - type (relation) of link to return
destActor - actor pointed to by links
Returns:
Array of links or null

getLink

Link[] getLink(java.lang.String type,
               Actor sourceActor,
               Actor destActor)
Returns all links of the given type (relation) type going from actor sourceActor to actor destActor or null. This is typically 1 link or null, but the spec does not forbid multiple links of the same type (relation) between two actors.

Parameters:
type - type (relation) of the link to return
sourceActor - starting point of the link
destActor - actor pointed to by links
Returns:
Array of links or null

getLinkTypes

java.lang.String[] getLinkTypes()
Returns all link types currently in this graph or null if no links are present.

Returns:
array of link types

getSubGraph

Graph[] getSubGraph(Query q)
Return newly created subgraphs that matches the given query FIXME: Currently not implemented in any graph. FIXME: Query structure needs to be defined.

Parameters:
q - query object to be executed.
Returns:
Array of graphs created by the query or null if none are created

setSubGraph

void setSubGraph(Query q)
Same as getSubGraph but the resulting graphs are stored internally NOTE: this interface may be removed.

Parameters:
q - Query to be executed

getProperty

Property[] getProperty()
Returns an array of all properties associated with this object or null if none exist

Returns:
Array of properties

getProperty

Property getProperty(java.lang.String type)
Return a property named by the given string or null if no property by this name exists

Parameters:
type - property's name
Returns:
Given property

add

void add(Property prop)
Add a property to this graph. If a property by this name already exists, it is overwritten with the given property.

Parameters:
prop - property to be added.

getPathSet

PathSet[] getPathSet()
Return all PathSets associated with this graph. Null if no PathSets are in the current graph.

Returns:
Array of PathSets

getPathSet

PathSet getPathSet(java.lang.String id)
Return the named PathSet. Returns null if no PathSet of the given ID exists.

Parameters:
id - ID of the PathSet to return
Returns:
PathSet specified by this ID

add

void add(PathSet pathSet)
Add a PathSet to this graph. If another PathSet of the same ID exists, it will be overwritten.

Parameters:
pathSet - PathSet to be added to this graph

setID

void setID(java.lang.String id)
Set this graph's ID to this value. Graph ID's must be unique.

Parameters:
id - graph ID

getID

java.lang.String getID()
Return the ID associated with this Graph

Returns:
ID

commit

void commit()
Commit the contents to database or storage. This is a null operation for memory only objects. (Delaying committing changes to be in batches can result in a massive decrease in execution time.)


add

void add(Graph g)
Add a graph (g) to the graph. Will be changed to be a graph helper - deprecated by addChild(Graph g)

Parameters:
g - graph to be added

close

void close()
Close database connections or write to file. Operations on a graph after close are undefined.


anonymize

void anonymize()
Replaces all actor IDs with an anonymous numeric ID.


getParent

Graph getParent()
Returns the parent graph of this object or null if this is a root graph

Returns:
parent graph

getChildren

Graph[] getChildren()
Returns the children graphs of this object or null if none exist

Returns:
Array of graphs that are children of this graph

getChildren

Graph getChildren(java.lang.String id)
Returns the children graph with the given id or null if there is not a child with that name.

Parameters:
id - ID of the graph to return
Returns:
Graph with the given ID

addChild

void addChild(Graph g)
Set the given graph to be a child of the current graph. NOTE: this does not verify that all actors and links only reference actors or links in the parent - this is the responsibility of the caller.

Parameters:
g - Child Graph

getSubGraph

Graph getSubGraph(java.util.Properties props,
                  java.util.Set<Actor> actor)
                  throws java.lang.Exception
Creates a new graph from the current graph using the Properties props containing the actors actor and all links that link between actors in actor.

Parameters:
props - Properties for creating a new Graph
actor - subset of graph's actors to make the subgraph from
Returns:
child graph of this graph
Throws:
java.lang.Exception - if actor is null or properties is null

getGraphs

Graph[] getGraphs(java.util.regex.Pattern pattern)
Creates an array of graph objects. Created as follows: if the graph matches, it adds itself to the array, else it recursively checks every child. This ensures that algorithms only execute at one level of the tree.

Parameters:
pattern - Regular expression for identifying graphs
Returns:
array of graphs or an empty graph array if no graph matches

getParameters

Parameter[] getParameters()
Obtain a computer-readable description of the parameters and options this graph supports

Returns:
Description of all parameters this graph object supports.

init

void init(java.util.Properties props)
Set the parameters of this graph from the following property object.

Parameters:
props - properties to be set

getActorCount

int getActorCount(java.lang.String mode)
Returns the number of actors of the given type

Parameters:
mode - type of actor to query
Returns:
int number of actors of the given type