nz.ac.waikato.mcennis.rat.graph
Class Clique

java.lang.Object
  extended by nz.ac.waikato.mcennis.rat.graph.model.ModelShell
      extended by nz.ac.waikato.mcennis.rat.graph.Clique
All Implemented Interfaces:
java.io.Serializable, java.lang.Comparable, Graph, Model, ParsedObject

public class Clique
extends ModelShell
implements Graph, java.lang.Comparable

Class for describing a completely connected subgraph. No link information is kept - only the actors are stored. Unlike more general graphs, this graph class can only be a leaf graph and must have a parent graph. The graph is populated by checking against the parent to see if clique-conditions still holds

See Also:
Serialized Form

Field Summary
 
Fields inherited from class nz.ac.waikato.mcennis.rat.graph.model.ModelShell
listener
 
Constructor Summary
Clique()
          Creates a new instance of Clique
 
Method Summary
 void add(Actor u)
          Adds an actor to the clique if The parent is defined The parent contains the actor The actor is pointed to by all previous actors The actor points to every existing actor in the clique
 void add(Graph g)
          Add a graph (g) to the graph.
 void add(Link link)
          Intentionally a null operation - links are added implicitly by add(Actor)
 void add(PathSet pathSet)
          Intentionally a null operation - paths do no make much sense on a clique
 void add(Property prop)
          Add a property to this graph.
 void addChild(Graph g)
          Leaf graph only, so intentionally null
 void anonymize()
          FIXME: anonymizer not implemented
protected  boolean checkLinks(Actor u)
          Determines if the actor to be added links to all elements of the clique
 void close()
          Close database connections or write to file.
 void commit()
          Commit the contents to database or storage.
 int compareTo(java.lang.Object o)
          CompareTo operator for Cliques.
 Clique duplicate()
          Create a duplicate Clique that is equal to the original
 boolean equals(java.lang.Object obj)
          Equals iff compareTo=0.
 Clique expand(Actor u)
          Identical to add(Actor u) except that this Clique is unchanged and a new Clique is returned.
 java.util.HashSet<Clique> expand(Graph g)
          Given this clique (and the graph) - generate all cliques of one bigger size that have this clique as a subclique where the new actor is greater (by compareTo) than any other actor in the clique.
 java.util.List<Actor> getActor()
          Retrieve an array of all actors of all types.
 java.util.List<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.util.Iterator<Actor> getActorIterator(java.lang.String type)
          Create a read only iterator over all actors.
 java.util.List<java.lang.String> getActorTypes()
          List all types - returns null if no actors exist.
 java.util.List<Graph> getChildren()
          Leaf graph only, so intentionally null
 Graph getChildren(java.lang.String id)
          Leaf graph only, so intentionally null
 java.util.Iterator<Graph> getChildrenIterator()
           
 Graph[] getGraphs(java.util.regex.Pattern pattern)
          Deprecated.  
 java.lang.String getID()
          Return the ID associated with this Graph
 java.util.List<Actor> getIntersection()
          Returns an unsorted array of actors that every member of the clique points to.
 java.util.List<Link> getLink()
          Null operation - links are implicit, not explicitly defined.
 java.util.List<Link> getLink(java.lang.String type)
          Null operation - links are implicit, not explicitly defined.
 java.util.List<Link> getLink(java.lang.String type, Actor sourceActor, Actor destActor)
          Null operation - links are implicit, not explicitly defined.
 java.util.Iterator<Link> getLinkByDesinationIterator(java.lang.String type, Actor destActor)
           
 java.util.List<Link> getLinkByDestination(java.lang.String type, Actor destActor)
          Null operation - links are implicit, not explicitly defined.
 java.util.List<Link> getLinkBySource(java.lang.String type, Actor sourceActor)
          Null operation - links are implicit, not explicitly defined.
 java.util.Iterator<Link> getLinkBySourceIterator(java.lang.String type, Actor sourceActor)
           
 java.util.Iterator<Link> getLinkIterator()
           
 java.util.Iterator<Link> getLinkIterator(java.lang.String type)
           
 java.util.Iterator<Link> getLinkIterator(java.lang.String type, Actor sourceActor, Actor destActor)
           
 java.util.List<java.lang.String> getLinkTypes()
          Null operation - links are implicit, not explicitly defined.
 Actor getMaxActor()
          Return the largest (by compareTo) actor in this clique.
 Properties getParameter()
          Obtain a computer-readable description of the parameters and options this graph supports
 Parameter getParameter(java.lang.String name)
           
 Graph getParent()
          Returns the parent graph of this object or null if this is a root graph
 java.util.List<PathSet> getPathSet()
          Intentionally a null operation - paths do no make much sense on a clique
 PathSet getPathSet(java.lang.String id)
          Intentionally a null operation - paths do no make much sense on a clique
 java.util.Iterator<PathSet> getPathSetIterator()
           
 java.util.List<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
 java.util.Iterator<Property> getPropertyIterator()
           
 Graph getSubGraph(Properties props, java.util.Set<Actor> actor)
          Intentionally null since this graph can have no children.
 void init(Properties props)
          Set the parameters of this graph from the following property object.
protected  void internalExpand(Actor u)
          Adds a new actor to the graph if the new graph will still be a clique
 Graph prototype()
           
 void remove(Actor u)
          Remove actor intentionally a null operation
 void remove(Link ul)
          Intentionally a null operation - links are added implicitly by add(Actor) so removing them makes no sense (unless an actor is removed)
 void removeProperty(java.lang.String ID)
           
 void setActorType(java.lang.String type)
          Establishes the type (mode) of actor this clique pulls from
 void setID(java.lang.String id)
          Set this graph's ID to this value.
 void setRelation(java.lang.String rel)
          Establishes which link type (relation) determines whether an acotr (node) belongs in a clique or not
 void setSubGraph(Query q)
          Intentionally null since this class can not have child graphs
protected  void start(Actor u)
          Initializes a clique - add an actor and initialize the intersection HashSet to all destinations this object links to (by keeping a set of all actors that are linked to by all actors in a clique, determining whether a new actor belongs is O(n) with the size of the clique for actors in the set and constant for those not.)
 Graph transform()
          Takes the existing Clique graph and transforms it into the graph type returned by the GrahphFactory object.
 
Methods inherited from class nz.ac.waikato.mcennis.rat.graph.model.ModelShell
addListener, fireChange
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface nz.ac.waikato.mcennis.rat.graph.model.Model
addListener
 

Constructor Detail

Clique

public Clique()
Creates a new instance of Clique

Method Detail

add

public void add(Actor u)
Adds an actor to the clique if

Specified by:
add in interface Graph
Parameters:
u - actor to be (potentially) added to this clique.

add

public void add(Link link)
Intentionally a null operation - links are added implicitly by add(Actor)

Specified by:
add in interface Graph
Parameters:
link - ignored

remove

public void remove(Actor u)
Remove actor intentionally a null operation

Specified by:
remove in interface Graph
Parameters:
u - user to be removed from the graph.

remove

public void remove(Link ul)
Intentionally a null operation - links are added implicitly by add(Actor) so removing them makes no sense (unless an actor is removed)

Specified by:
remove in interface Graph
Parameters:
ul - ignored

getActor

public Actor getActor(java.lang.String type,
                      java.lang.String ID)
Description copied from interface: Graph
Retrieve the users that has the given ID. Returns null if no user is in the graph with that ID.

Specified by:
getActor in interface Graph
ID - ID string identifying an user
Returns:
user object who has this ID or null if it is not present

getActor

public java.util.List<Actor> getActor()
Description copied from interface: Graph
Retrieve an array of all actors of all types. Returns null if no actors are in the graph.

Specified by:
getActor in interface Graph
Returns:
array of all users in the graph

getActor

public java.util.List<Actor> getActor(java.lang.String type)
Description copied from interface: Graph
Retrieve an array of all actors of a given type. Returns null if there are no actors of that type in the graph.

Specified by:
getActor in interface Graph
Parameters:
type - class of actor to return
Returns:
array of actors of the given type

getActorTypes

public java.util.List<java.lang.String> getActorTypes()
Description copied from interface: Graph
List all types - returns null if no actors exist.

Specified by:
getActorTypes in interface Graph
Returns:
array of all type names in this graph

getLink

public java.util.List<Link> getLink()
Null operation - links are implicit, not explicitly defined.

Specified by:
getLink in interface Graph
Returns:
array of all userlinks or null

getLink

public java.util.List<Link> getLink(java.lang.String type)
Null operation - links are implicit, not explicitly defined.

Specified by:
getLink in interface Graph
Returns:
array of all user links of a given type or null

getLinkBySource

public java.util.List<Link> getLinkBySource(java.lang.String type,
                                            Actor sourceActor)
Null operation - links are implicit, not explicitly defined.

Specified by:
getLinkBySource in interface Graph
Parameters:
type - type (relation) of link to return
sourceActor - starting point of the link
Returns:
Array of links or null

getLinkByDestination

public java.util.List<Link> getLinkByDestination(java.lang.String type,
                                                 Actor destActor)
Null operation - links are implicit, not explicitly defined.

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

getLink

public java.util.List<Link> getLink(java.lang.String type,
                                    Actor sourceActor,
                                    Actor destActor)
Null operation - links are implicit, not explicitly defined.

Specified by:
getLink in interface Graph
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

public java.util.List<java.lang.String> getLinkTypes()
Null operation - links are implicit, not explicitly defined.

Specified by:
getLinkTypes in interface Graph
Returns:
array of link types

setSubGraph

public void setSubGraph(Query q)
Intentionally null since this class can not have child graphs

Parameters:
q - ignored

getProperty

public java.util.List<Property> getProperty()
Description copied from interface: Graph
Returns an array of all properties associated with this object or null if none exist

Specified by:
getProperty in interface Graph
Returns:
Array of properties

getProperty

public Property getProperty(java.lang.String type)
Description copied from interface: Graph
Return a property named by the given string or null if no property by this name exists

Specified by:
getProperty in interface Graph
Parameters:
type - property's name
Returns:
Given property

add

public void add(Property prop)
Description copied from interface: Graph
Add a property to this graph. If a property by this name already exists, it is overwritten with the given property.

Specified by:
add in interface Graph
Parameters:
prop - property to be added.

getPathSet

public java.util.List<PathSet> getPathSet()
Intentionally a null operation - paths do no make much sense on a clique

Specified by:
getPathSet in interface Graph
Returns:
Array of PathSets

getPathSet

public PathSet getPathSet(java.lang.String id)
Intentionally a null operation - paths do no make much sense on a clique

Specified by:
getPathSet in interface Graph
Parameters:
id - ignored
Returns:
PathSet specified by this ID

add

public void add(PathSet pathSet)
Intentionally a null operation - paths do no make much sense on a clique

Specified by:
add in interface Graph
Parameters:
pathSet - ignored

setRelation

public void setRelation(java.lang.String rel)
Establishes which link type (relation) determines whether an acotr (node) belongs in a clique or not

Parameters:
rel - name of the link type (relation)

setID

public void setID(java.lang.String id)
Description copied from interface: Graph
Set this graph's ID to this value. Graph ID's must be unique.

Specified by:
setID in interface Graph
Parameters:
id - graph ID

getID

public java.lang.String getID()
Description copied from interface: Graph
Return the ID associated with this Graph

Specified by:
getID in interface Graph
Returns:
ID

start

protected void start(Actor u)
Initializes a clique - add an actor and initialize the intersection HashSet to all destinations this object links to (by keeping a set of all actors that are linked to by all actors in a clique, determining whether a new actor belongs is O(n) with the size of the clique for actors in the set and constant for those not.)

Parameters:
u - actor that initializes this clique - technically not a clique until the second actor is added.

internalExpand

protected void internalExpand(Actor u)
Adds a new actor to the graph if the new graph will still be a clique

Parameters:
u - actor to be added

checkLinks

protected boolean checkLinks(Actor u)
Determines if the actor to be added links to all elements of the clique

Parameters:
u - actor to be checked
Returns:
whether or not this actor links to all other actors in the clique

compareTo

public int compareTo(java.lang.Object o)
CompareTo operator for Cliques. Throws a ClassCastException if the object compared is not a Clique Checks:
  1. sort Actors - first clique with a smaller (by compareTo) actor is is smaller by compareTo.
  2. sort Properties - firts clique with a smaller (by compareTo) property is smaller by compareTo.
  3. return 0

Specified by:
compareTo in interface java.lang.Comparable
Parameters:
o - Clique to be compared against

equals

public boolean equals(java.lang.Object obj)
Equals iff compareTo=0. Does not throw class cast exception.

Overrides:
equals in class java.lang.Object
Parameters:
obj - object to check for equality

expand

public java.util.HashSet<Clique> expand(Graph g)
Given this clique (and the graph) - generate all cliques of one bigger size that have this clique as a subclique where the new actor is greater (by compareTo) than any other actor in the clique. Returns null if no such cliques exist.

Parameters:
g - parent graph
Returns:
HashSet containing cliques or null

duplicate

public Clique duplicate()
Create a duplicate Clique that is equal to the original

Returns:
duplicate clique

getActorIterator

public java.util.Iterator<Actor> getActorIterator(java.lang.String type)
Description copied from interface: Graph
Create a read only iterator over all actors.

Specified by:
getActorIterator in interface Graph
Parameters:
type - type (mode) of actor to return
Returns:
iterator over all actors of the given type

setActorType

public void setActorType(java.lang.String type)
Establishes the type (mode) of actor this clique pulls from

Parameters:
type - name of the type (mode) of actor.

commit

public void commit()
Description copied from interface: Graph
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.)

Specified by:
commit in interface Graph

add

public void add(Graph g)
Description copied from interface: Graph
Add a graph (g) to the graph. Will be changed to be a graph helper - deprecated by addChild(Graph g)

Specified by:
add in interface Graph
Parameters:
g - graph to be added

close

public void close()
Description copied from interface: Graph
Close database connections or write to file. Operations on a graph after close are undefined.

Specified by:
close in interface Graph

anonymize

public void anonymize()
FIXME: anonymizer not implemented

Specified by:
anonymize in interface Graph

getParent

public Graph getParent()
Description copied from interface: Graph
Returns the parent graph of this object or null if this is a root graph

Specified by:
getParent in interface Graph
Returns:
parent graph

getChildren

public java.util.List<Graph> getChildren()
Leaf graph only, so intentionally null

Specified by:
getChildren in interface Graph
Returns:
Array of graphs that are children of this graph

getChildren

public Graph getChildren(java.lang.String id)
Leaf graph only, so intentionally null

Specified by:
getChildren in interface Graph
Parameters:
id - ID of the graph to return
Returns:
Graph with the given ID

addChild

public void addChild(Graph g)
Leaf graph only, so intentionally null

Specified by:
addChild in interface Graph
Parameters:
g - Child Graph

expand

public Clique expand(Actor u)
Identical to add(Actor u) except that this Clique is unchanged and a new Clique is returned. If the new group of actors is not a clique, return null.

Parameters:
u - Actor to be added
Returns:
new clique containing this actor

getIntersection

public java.util.List<Actor> getIntersection()
Returns an unsorted array of actors that every member of the clique points to. If this is none - return null

Returns:
array of actors

getMaxActor

public Actor getMaxActor()
Return the largest (by compareTo) actor in this clique. Returns null if this clique si empty.

Returns:
largest actor;

getSubGraph

public Graph getSubGraph(Properties props,
                         java.util.Set<Actor> actor)
Intentionally null since this graph can have no children.


getGraphs

public Graph[] getGraphs(java.util.regex.Pattern pattern)
Deprecated. 

Returns the node closest to root whose ID matches the given pattern. Obsoleted by GraphByID query object.

Parameters:
pattern -
Returns:

getParameter

public Properties getParameter()
Description copied from interface: Graph
Obtain a computer-readable description of the parameters and options this graph supports

Specified by:
getParameter in interface Graph
Returns:
Description of all parameters this graph object supports.

init

public void init(Properties props)
Description copied from interface: Graph
Set the parameters of this graph from the following property object.

Specified by:
init in interface Graph
Parameters:
props - properties to be set

getActorCount

public int getActorCount(java.lang.String mode)
Description copied from interface: Graph
Returns the number of actors of the given type

Specified by:
getActorCount in interface Graph
Parameters:
mode - type of actor to query
Returns:
int number of actors of the given type

transform

public Graph transform()
Takes the existing Clique graph and transforms it into the graph type returned by the GrahphFactory object.

Returns:
new graph with the same content as this Clique object.

getActorIterator

public java.util.Iterator<Actor> getActorIterator()
Specified by:
getActorIterator in interface Graph

getLinkIterator

public java.util.Iterator<Link> getLinkIterator()
Specified by:
getLinkIterator in interface Graph

getLinkIterator

public java.util.Iterator<Link> getLinkIterator(java.lang.String type)
Specified by:
getLinkIterator in interface Graph

getLinkBySourceIterator

public java.util.Iterator<Link> getLinkBySourceIterator(java.lang.String type,
                                                        Actor sourceActor)
Specified by:
getLinkBySourceIterator in interface Graph

getLinkByDesinationIterator

public java.util.Iterator<Link> getLinkByDesinationIterator(java.lang.String type,
                                                            Actor destActor)
Specified by:
getLinkByDesinationIterator in interface Graph

getLinkIterator

public java.util.Iterator<Link> getLinkIterator(java.lang.String type,
                                                Actor sourceActor,
                                                Actor destActor)
Specified by:
getLinkIterator in interface Graph

getPropertyIterator

public java.util.Iterator<Property> getPropertyIterator()
Specified by:
getPropertyIterator in interface Graph

getPathSetIterator

public java.util.Iterator<PathSet> getPathSetIterator()
Specified by:
getPathSetIterator in interface Graph

getChildrenIterator

public java.util.Iterator<Graph> getChildrenIterator()
Specified by:
getChildrenIterator in interface Graph

getParameter

public Parameter getParameter(java.lang.String name)
Specified by:
getParameter in interface Graph

prototype

public Graph prototype()
Specified by:
prototype in interface Graph

removeProperty

public void removeProperty(java.lang.String ID)
Specified by:
removeProperty in interface Graph

Get Relational Analysis Toolkit at SourceForge.net. Fast, secure and Free Open Source software downloads