Search this API

y.layout.router
Class BusRepresentations

java.lang.Object
  extended by y.layout.router.BusRepresentations

public class BusRepresentations
extends Object

This class provides helpers to convert between buses given by complete subgraphs and buses represented by specific hub nodes.

In a representation by means of hubs, each connected subgraph induced by hubs establishes a bus. All regular nodes (non-hubs) which are connected to hubs of the same component are end-nodes of the same bus. In other words, nodes which are reachable on paths consisting of only hubs belong to the same bus. Of course, a node can be an end-node of more than one bus.

Since a bus models a group of nodes in which every node is connected to every other node, it can be represented as a complete subgraph of these nodes. To distinguish buses in this representation, each edge must be associated with a unique ID which identifies the bus it is associated to. This is the representation expected by BusRouter.


Field Summary
static Object SOURCE_ID_DPKEY
          DataProvider key used to transfer a user-defined object from each original edge to the respective newly created edge.
static Object TARGET_ID_DPKEY
          DataProvider key used to transfer a user-defined object from each original edge to the respective newly created edge.
 
Method Summary
static EdgeList replaceHubsBySubgraph(LayoutGraph graph, DataProvider hubMarker, DataAcceptor descriptorAcceptor)
          Changes the representation of buses from hubs to complete subgraphs.
static EdgeList replaceHubsBySubgraph(LayoutGraph graph, EdgeList[] hubEdgesLists, DataProvider hubMarker, DataProvider fixedMarker, DataAcceptor descriptorAcceptor)
          Changes the representation of buses from hubs to complete subgraphs by creating new edges between regular nodes and removing the hubs.
static void replaceSubgraphByHubs(LayoutGraph graph, EdgeCursor edgeCursor, DataProvider descriptorProvider, DataAcceptor busIDAcceptor)
          Changes the representation of buses from complete subgraphs to hubs by replacing intersection points by hubs.
static EdgeList[] toEdgeLists(Graph graph, DataProvider hubMarker)
          Calculates for every bus represented by hubs a list of all of its edges.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SOURCE_ID_DPKEY

public static final Object SOURCE_ID_DPKEY
DataProvider key used to transfer a user-defined object from each original edge to the respective newly created edge. Algorithms which respect this key expect the associated data provider to be also an instance of DataAcceptor to enable the storage of the data object for the new edge. Since there is no one-to-one mapping between original and new edges, the data provider of this key is responsible for the edges whose source end is a regular node.


TARGET_ID_DPKEY

public static final Object TARGET_ID_DPKEY
DataProvider key used to transfer a user-defined object from each original edge to the respective newly created edge. Algorithms which respect this key expect the associated data provider to be also an instance of DataAcceptor to enable the storage of the data object for the new edge. Since there is no one-to-one mapping between original and new edges, the data provider of this key is responsible for the edges whose target end is a regular node.

Method Detail

toEdgeLists

public static EdgeList[] toEdgeLists(Graph graph,
                                     DataProvider hubMarker)
Calculates for every bus represented by hubs a list of all of its edges. Note that this method cannot return isolated hubs and that each edge between two regular nodes establishes a separate bus.

Parameters:
graph - the graph
hubMarker - a DataProvider which returns true if and only if a node is a hub
Returns:
an array of EdgeLists. Each list contains all edges of a bus.

replaceHubsBySubgraph

public static EdgeList replaceHubsBySubgraph(LayoutGraph graph,
                                             DataProvider hubMarker,
                                             DataAcceptor descriptorAcceptor)
Changes the representation of buses from hubs to complete subgraphs. This method calls replaceHubsBySubgraph(graph, calculateBusEdgeLists(graph, hubMarker), hubMarker, false, busDescriptors).

See Also:
replaceHubsBySubgraph(LayoutGraph, EdgeList[], DataProvider, DataProvider, DataAcceptor), toEdgeLists(Graph, DataProvider)

replaceHubsBySubgraph

public static EdgeList replaceHubsBySubgraph(LayoutGraph graph,
                                             EdgeList[] hubEdgesLists,
                                             DataProvider hubMarker,
                                             DataProvider fixedMarker,
                                             DataAcceptor descriptorAcceptor)
Changes the representation of buses from hubs to complete subgraphs by creating new edges between regular nodes and removing the hubs. This method respects multiple connections of nodes and creates appropriate BusDescriptors consisting of the bus ID and source and target group IDs.

The path of each new edge follows the route defined by the component of the hubs. If the subgraph of hubs is not a tree, these paths are ambiguous. In this case, an arbitrary tree is computed from the hub's subgraph which defines all the paths.

Parameters:
graph - the graph of the bus
hubEdgesLists - an EdgeList for each bus
hubMarker - a DataProvider that returns true if and only if a node is a hub
fixedMarker - a DataProvider that returns true if and only if an edge is fixed
descriptorAcceptor - a DataAcceptor to which the created bus descriptors are set
Returns:
a list of the created edges

replaceSubgraphByHubs

public static void replaceSubgraphByHubs(LayoutGraph graph,
                                         EdgeCursor edgeCursor,
                                         DataProvider descriptorProvider,
                                         DataAcceptor busIDAcceptor)
Changes the representation of buses from complete subgraphs to hubs by replacing intersection points by hubs. The edges must form an orthogonal, cycle-free bus, otherwise an IllegalStateException is thrown.

Throws:
IllegalStateException - if the path of an edge is not orthogonal or if some paths form a cycle
Parameters:
graph - the graph of the bus
edgeCursor - an EdgeCursor of the regular edges
descriptorProvider - a DataProvider that provides a BusDescriptor for each edge
busIDAcceptor - an optional DataAcceptor. If specified, the bus ID for each new edge is set to this data acceptor

© Copyright 2000-2013,
yWorks GmbH.
All rights reserved.