org.dbe.eve.simulator
Class SMERelationships

java.lang.Object
  extended by org.dbe.eve.simulator.SMERelationships

public class SMERelationships
extends java.lang.Object

SMERelationships stores a table with Relationships between SMEs Example: This table A B C A 0 1 0 B 1 0 1 C 0 1 0 is stored in the 3 vectors smeNames = {A, B, C} relationShips = {{0, 1, 0}, {1, 0, 1}, {0, 1, 0}}

Author:
Roman Greil

Nested Class Summary
private  class SMERelationships.DijstraComparator
          DijstraComparator is used by the findNewFriend method, as Java anonymous classes do not support closures and the distance array is needed for the comparison.
 
Field Summary
(package private) static org.apache.log4j.Logger logger
           
private  double maxWeight
           
private  java.util.Vector relationShips
           
private  java.util.HashMap smeNames
           
 
Constructor Summary
SMERelationships()
           
 
Method Summary
 void addRelationship(java.lang.String from, java.lang.String to, int value)
          add a relationship to the table.
 int findNewFriend(int source, int target)
          Calculates the strenght of the connection between two companies that do not know each other.
 int getNumSMEs()
          returns the number of smes
 java.util.Vector getRelationships()
          returns the vector with the relationships
 int getSmeId(java.lang.String smeName)
          return the id of a sme
 java.lang.String getSmeNameById(int id)
          returns the name of a sme
 java.util.Vector getSMENames()
          returns all sme names as a vector
private  int getWeight(int i, int j)
          Gets the strength of the connection between company i and company j
 java.lang.String toString()
          Returns the relations ships as string
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

logger

static org.apache.log4j.Logger logger

maxWeight

private double maxWeight

relationShips

private java.util.Vector relationShips

smeNames

private java.util.HashMap smeNames
Constructor Detail

SMERelationships

public SMERelationships()
Method Detail

addRelationship

public void addRelationship(java.lang.String from,
                            java.lang.String to,
                            int value)
add a relationship to the table. If from or to sme does not exist, a new column and row will be created

Parameters:
from - the row name
to - the column name
value - the strength

toString

public java.lang.String toString()
Returns the relations ships as string

Overrides:
toString in class java.lang.Object

getSMENames

public java.util.Vector getSMENames()
returns all sme names as a vector


getRelationships

public java.util.Vector getRelationships()
returns the vector with the relationships


getSmeId

public int getSmeId(java.lang.String smeName)
return the id of a sme

Parameters:
smeName - the name of the sme

getSmeNameById

public java.lang.String getSmeNameById(int id)
returns the name of a sme

Parameters:
id - the id of the sme

getNumSMEs

public int getNumSMEs()
returns the number of smes


getWeight

private final int getWeight(int i,
                            int j)
Gets the strength of the connection between company i and company j

Parameters:
i - Company from
j - Company to
Returns:
The strength of the link (weight) from i to j

findNewFriend

public int findNewFriend(int source,
                         int target)
Calculates the strenght of the connection between two companies that do not know each other.

Parameters:
source - Company from
target - Company to
Returns:
the calculated strenght of the link