bcds.phison.io
Class PropertyBasedFormatter<V extends GraphIONode,E>

java.lang.Object
  extended by bcds.phison.io.PropertyBasedFormatter<V,E>
All Implemented Interfaces:
GraphFormatter<V,E>

public class PropertyBasedFormatter<V extends GraphIONode,E>
extends java.lang.Object
implements GraphFormatter<V,E>

Implements a simple "formatter" of node and link attributes. The attributes are formatted according to directives given in a comma-separated list of key=value pairs, called "properties". The nodes in the corresponding graph must implement the GraphIONode interface. The node properties supported are:

The link properties supported are:

Author:
Juan Segovia S.

Constructor Summary
PropertyBasedFormatter(TED<V,E> ted, java.lang.String node_prop, java.lang.String link_prop)
          Instantiates a formatter.
 
Method Summary
 java.lang.String getEdgeDesc(E e)
          Returns the attributes of link e.
 java.lang.String getEdgeExtraAttr(E e)
          Always returns the empty string.
 java.lang.String getVertexDesc(V v)
          Returns a description of node v.
 java.lang.String getVertexExtraAttr(V v)
          Always returns an empty string.
 java.lang.String getVertexId(V v)
          Returns the "id" attibute of parameter v, obtained via the node's "environment" (i.e., the equivalent of v.dumpToEnvironment().getStr("id")).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PropertyBasedFormatter

public PropertyBasedFormatter(TED<V,E> ted,
                              java.lang.String node_prop,
                              java.lang.String link_prop)
Instantiates a formatter.

Parameters:
ted - a TED object from which link attributes will be retrieved. It must not be null (though the link attributes themselves may; in this case, the missing attribute is omitted from the output).
node_prop - the node properties that should be returned.
Method Detail

getVertexId

public java.lang.String getVertexId(V v)
Returns the "id" attibute of parameter v, obtained via the node's "environment" (i.e., the equivalent of v.dumpToEnvironment().getStr("id")).

Specified by:
getVertexId in interface GraphFormatter<V extends GraphIONode,E>

getVertexDesc

public java.lang.String getVertexDesc(V v)
Returns a description of node v. If the node property is "i", the node id is returned. If it is "l", the label is returned.

If both i and l are present, the returned value is (symbolically) i + "-" + l (for example, "5-Berlin"). Furthermore:
if i and l are equal, only i is returned (avoid "5-5").
If l is empty, only i is returned (avoid "5-").
If i is empty and l is not, only l is returned (avoid "-5").

Specified by:
getVertexDesc in interface GraphFormatter<V extends GraphIONode,E>

getVertexExtraAttr

public java.lang.String getVertexExtraAttr(V v)
Always returns an empty string.

Specified by:
getVertexExtraAttr in interface GraphFormatter<V extends GraphIONode,E>

getEdgeDesc

public java.lang.String getEdgeDesc(E e)
Returns the attributes of link e. The values returned depend on what is present in the constructor's link_prop parameter: "cap=nn" when "c" is present. "res=nn" when "r" is present. "w=ff" when "w" is present, formatted with "%.5f". Note that any combination of these three values can be present. A space is added between the respective values, if necessary.

Specified by:
getEdgeDesc in interface GraphFormatter<V extends GraphIONode,E>

getEdgeExtraAttr

public java.lang.String getEdgeExtraAttr(E e)
Always returns the empty string.

Specified by:
getEdgeExtraAttr in interface GraphFormatter<V extends GraphIONode,E>