Class SimpleConnectionManager
- java.lang.Object
-
- de.unirostock.sems.bives.algorithm.SimpleConnectionManager
-
- All Implemented Interfaces:
de.unirostock.sems.xmlutils.comparison.ConnectionManager
public class SimpleConnectionManager extends Object implements de.unirostock.sems.xmlutils.comparison.ConnectionManager
- Author:
- Martin Scharm
-
-
Constructor Summary
Constructors Constructor Description SimpleConnectionManager(SimpleConnectionManager toCopy)
Instantiates a new connection manager as a copy of toCopy.SimpleConnectionManager(de.unirostock.sems.xmlutils.ds.TreeDocument docA, de.unirostock.sems.xmlutils.ds.TreeDocument docB)
Instantiates a new simple connection manager.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
addConnection(NodeConnection c)
Adds a new connection unless connection exists.void
addWeightToAllConnections(double value)
Add weight to all connections.void
deleteMatchedNodes(List<de.unirostock.sems.xmlutils.ds.TreeNode> vec)
Delete nodes of a vector which have connections.void
dropConnection(de.unirostock.sems.xmlutils.comparison.Connection c)
Drop a certain connection.void
dropConnection(de.unirostock.sems.xmlutils.ds.TreeNode node)
Drop all connections of a node.de.unirostock.sems.xmlutils.comparison.Connection
getConnectionForNode(de.unirostock.sems.xmlutils.ds.TreeNode node)
Gets the connections for node.de.unirostock.sems.xmlutils.comparison.Connection
getConnectionOfNodes(de.unirostock.sems.xmlutils.ds.TreeNode a, de.unirostock.sems.xmlutils.ds.TreeNode b)
Gets the connection of two certain nodes.List<de.unirostock.sems.xmlutils.ds.TreeNode>
getUnmatched(de.unirostock.sems.xmlutils.ds.TreeNode subtree, List<de.unirostock.sems.xmlutils.ds.TreeNode> unmatched)
Gets the unmatched nodes in a subtree.SimpleConnectionManager
intersection(SimpleConnectionManager cmgmt)
Create a ConnectionManager that contains only connections from this ConnectionManager and_another instance.boolean
parentsConnected(de.unirostock.sems.xmlutils.comparison.Connection c)
Check if parents connected.void
scaleWeightOfAllConnections(double value)
Scale the weight of all connections.SimpleConnectionManager
setDiff(SimpleConnectionManager cmgmt)
Create a ConnectionManager that contains only connections from this ConnectionManager which are not included in another instance.void
setWeightOfAllConnections(double value)
Sets the weight of all connections.SimpleConnectionManager
symDiff(SimpleConnectionManager cmgmt)
Create a ConnectionManager that contains only connections from this ConnectionManager and another instance and are not included in both managers.String
toString()
SimpleConnectionManager
union(SimpleConnectionManager cmgmt)
Create a ConnectionManager that combines all connections from this ConnectionManager and another instance.
-
-
-
Constructor Detail
-
SimpleConnectionManager
public SimpleConnectionManager(de.unirostock.sems.xmlutils.ds.TreeDocument docA, de.unirostock.sems.xmlutils.ds.TreeDocument docB)
Instantiates a new simple connection manager.- Parameters:
docA
- the original documentdocB
- the modified document
-
SimpleConnectionManager
public SimpleConnectionManager(SimpleConnectionManager toCopy) throws BivesConnectionException
Instantiates a new connection manager as a copy of toCopy.- Parameters:
toCopy
- the connection manager to copy- Throws:
BivesConnectionException
-
-
Method Detail
-
scaleWeightOfAllConnections
public void scaleWeightOfAllConnections(double value)
Scale the weight of all connections.- Parameters:
value
- the scale
-
addWeightToAllConnections
public void addWeightToAllConnections(double value)
Add weight to all connections.- Parameters:
value
- the value to add
-
setWeightOfAllConnections
public void setWeightOfAllConnections(double value)
Sets the weight of all connections.- Parameters:
value
- the new weight of all connections
-
addConnection
public boolean addConnection(NodeConnection c) throws BivesConnectionException
Adds a new connection unless connection exists. If connection exists, the weights are summed. Throws exception if one of the nodes already connected.- Parameters:
c
- the c connection to add- Returns:
- true, if c was added
- Throws:
BivesConnectionException
-
union
public SimpleConnectionManager union(SimpleConnectionManager cmgmt)
Create a ConnectionManager that combines all connections from this ConnectionManager and another instance. Weights are taken from this instance. E.g. given this is A and you pass B you'll get C = A u B Use with caution, very expensive!- Parameters:
cmgmt
- the ConnectionManager to join- Returns:
- the united connection manager, containing all connections
-
intersection
public SimpleConnectionManager intersection(SimpleConnectionManager cmgmt)
Create a ConnectionManager that contains only connections from this ConnectionManager and_another instance. Weights are taken from this instance. E.g. given this is A and you pass B you'll get C = A n B Use with caution, very expensive!- Parameters:
cmgmt
- the cmgmt- Returns:
- the connection manager
-
setDiff
public SimpleConnectionManager setDiff(SimpleConnectionManager cmgmt)
Create a ConnectionManager that contains only connections from this ConnectionManager which are not included in another instance. Weights are taken from this instance. E.g. given this is A and you pass B you'll get C = A \ B Use with caution, very expensive!- Parameters:
cmgmt
- the cmgmt- Returns:
- the connection manager
-
symDiff
public SimpleConnectionManager symDiff(SimpleConnectionManager cmgmt)
Create a ConnectionManager that contains only connections from this ConnectionManager and another instance and are not included in both managers. Weights are taken from this instance. E.g. given this is A and you pass B you'll get C = (A u B) \ (A n B) = (A \ B) u (B \ A) Use with caution, very VERY expensive!- Parameters:
cmgmt
- the cmgmt- Returns:
- the connection manager
-
dropConnection
public void dropConnection(de.unirostock.sems.xmlutils.ds.TreeNode node)
Drop all connections of a node. In general you'll find a correct connection for a node, so you'll drop all connections and afterwards add the good one.- Parameters:
node
- the node to liberate
-
dropConnection
public void dropConnection(de.unirostock.sems.xmlutils.comparison.Connection c)
Drop a certain connection.- Parameters:
c
- the connection
-
getConnectionForNode
public de.unirostock.sems.xmlutils.comparison.Connection getConnectionForNode(de.unirostock.sems.xmlutils.ds.TreeNode node)
Gets the connections for node. Returns null if there is no connection for this node.- Specified by:
getConnectionForNode
in interfacede.unirostock.sems.xmlutils.comparison.ConnectionManager
- Parameters:
node
- the node- Returns:
- the connections for node
-
getConnectionOfNodes
public de.unirostock.sems.xmlutils.comparison.Connection getConnectionOfNodes(de.unirostock.sems.xmlutils.ds.TreeNode a, de.unirostock.sems.xmlutils.ds.TreeNode b)
Gets the connection of two certain nodes. Returns null if nodes are not connected.- Parameters:
a
- the ab
- the b- Returns:
- the connection of nodes
-
getUnmatched
public List<de.unirostock.sems.xmlutils.ds.TreeNode> getUnmatched(de.unirostock.sems.xmlutils.ds.TreeNode subtree, List<de.unirostock.sems.xmlutils.ds.TreeNode> unmatched)
Gets the unmatched nodes in a subtree.- Parameters:
subtree
- the subtreeunmatched
- the vector in which the unmatched nodes are collected- Returns:
- the the vector in which the unmatched nodes are collected
-
deleteMatchedNodes
public void deleteMatchedNodes(List<de.unirostock.sems.xmlutils.ds.TreeNode> vec)
Delete nodes of a vector which have connections.- Parameters:
vec
- the vector of nodes to modify
-
parentsConnected
public boolean parentsConnected(de.unirostock.sems.xmlutils.comparison.Connection c)
Check if parents connected. Parents are connected if there exists a connection between the parents of both nodes or both nodes don't have a parent (~> parents of two roots are connected!)- Specified by:
parentsConnected
in interfacede.unirostock.sems.xmlutils.comparison.ConnectionManager
- Parameters:
c
- the c- Returns:
- true, if connected
-
-