Class DotExporter<N extends PlannerGraph.Node,E extends PlannerGraph.Edge>
- java.lang.Object
-
- com.apple.foundationdb.record.query.plan.temp.explain.GraphExporter<N,E>
-
- com.apple.foundationdb.record.query.plan.temp.explain.DotExporter<N,E>
-
- Type Parameters:
N
- the network node typeE
- the network edge type
public class DotExporter<N extends PlannerGraph.Node,E extends PlannerGraph.Edge> extends GraphExporter<N,E>
Exports a graph into a DOT file.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.apple.foundationdb.record.query.plan.temp.explain.GraphExporter
GraphExporter.Cluster<N,E>, GraphExporter.ClusterProvider<N,E>, GraphExporter.ComponentAttributeProvider<T>, GraphExporter.ComponentIdProvider<T>, GraphExporter.ExporterContext
-
-
Field Summary
Fields Modifier and Type Field Description static String
DEFAULT_GRAPH_ID
Default graph id used by the exporter.
-
Constructor Summary
Constructors Constructor Description DotExporter(GraphExporter.ComponentIdProvider<N> vertexIDProvider, GraphExporter.ComponentAttributeProvider<N> vertexAttributeProvider, GraphExporter.ComponentAttributeProvider<E> edgeAttributeProvider, Map<String,Attribute> graphAttributes, GraphExporter.ClusterProvider<N,E> clusterProvider)
Constructs a new DotExporter object with the given ID, label, attribute, and graph ID providers.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
getEdgeLabel(Attribute label)
String
getNodeLabel(Attribute name, Attribute details, Map<String,Attribute> nodeAttributes)
protected boolean
isValidId(String idCandidate)
Test if the ID candidate is a valid ID.protected void
renderCluster(GraphExporter.ExporterContext context, String clusterId, GraphExporter.Cluster<N,E> cluster, Map<String,Attribute> attributes, String indentation)
Render a sub cluster.protected void
renderClusters(GraphExporter.ExporterContext context, @NonNull Set<N> currentNodes, Collection<GraphExporter.Cluster<N,E>> nestedClusters, String prefix, String indentation)
protected void
renderClusters(GraphExporter.ExporterContext context, Collection<GraphExporter.Cluster<N,E>> clusters)
Render all sub clusters in a given network.protected void
renderEdge(GraphExporter.ExporterContext context, boolean isDirected, N source, N target, Map<String,Attribute> attributes)
Render an edge.protected void
renderFooter(GraphExporter.ExporterContext context)
Compute the footer.protected void
renderGraphAttributes(GraphExporter.ExporterContext context, Map<String,Attribute> attributes)
Render the global graph attributes.protected void
renderHeader(GraphExporter.ExporterContext context, com.google.common.graph.ImmutableNetwork<N,E> graph)
Render the header.protected void
renderNode(GraphExporter.ExporterContext context, N node, Map<String,Attribute> attributes)
Render a node.-
Methods inherited from class com.apple.foundationdb.record.query.plan.temp.explain.GraphExporter
exportGraph, getClusterProvider, getEdgeAttributeProvider, getEdgeID, getEdgeIDProvider, getGraphAttributes, getVertexAttributeProvider, getVertexID, getVertexIDProvider, getVertexIds, renderEdges, renderNodes
-
-
-
-
Field Detail
-
DEFAULT_GRAPH_ID
public static final String DEFAULT_GRAPH_ID
Default graph id used by the exporter.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
DotExporter
public DotExporter(@Nonnull GraphExporter.ComponentIdProvider<N> vertexIDProvider, @Nonnull GraphExporter.ComponentAttributeProvider<N> vertexAttributeProvider, @Nonnull GraphExporter.ComponentAttributeProvider<E> edgeAttributeProvider, @Nonnull Map<String,Attribute> graphAttributes, @Nonnull GraphExporter.ClusterProvider<N,E> clusterProvider)
Constructs a new DotExporter object with the given ID, label, attribute, and graph ID providers. Note that if a label provider conflicts with a label-supplying attribute provider, the label provider is given precedence.- Parameters:
vertexIDProvider
- for generating vertex IDs. Must not be null.vertexAttributeProvider
- for generating vertex attributes. If null, vertex attributes will not be written to the file.edgeAttributeProvider
- for generating edge attributes. If null, edge attributes will not be written to the file.graphAttributes
- map of global attributesclusterProvider
- for partitioning the graph into clusters if warranted
-
-
Method Detail
-
isValidId
protected boolean isValidId(@Nonnull String idCandidate)
Test if the ID candidate is a valid ID.- Specified by:
isValidId
in classGraphExporter<N extends PlannerGraph.Node,E extends PlannerGraph.Edge>
- Parameters:
idCandidate
- the ID candidate.- Returns:
true
if it is valid;false
otherwise.
-
renderHeader
protected void renderHeader(@Nonnull GraphExporter.ExporterContext context, @Nonnull com.google.common.graph.ImmutableNetwork<N,E> graph)
Description copied from class:GraphExporter
Render the header. To be implemented by subclass.- Specified by:
renderHeader
in classGraphExporter<N extends PlannerGraph.Node,E extends PlannerGraph.Edge>
- Parameters:
context
- the contextgraph
- the graph
-
renderGraphAttributes
protected void renderGraphAttributes(@Nonnull GraphExporter.ExporterContext context, @Nonnull Map<String,Attribute> attributes)
Description copied from class:GraphExporter
Render the global graph attributes. To be implemented by subclass.- Specified by:
renderGraphAttributes
in classGraphExporter<N extends PlannerGraph.Node,E extends PlannerGraph.Edge>
- Parameters:
context
- the contextattributes
- the attributes of the graph
-
renderNode
protected void renderNode(@Nonnull GraphExporter.ExporterContext context, @Nonnull N node, @Nonnull Map<String,Attribute> attributes)
Description copied from class:GraphExporter
Render a node. To be implemented by subclass.- Specified by:
renderNode
in classGraphExporter<N extends PlannerGraph.Node,E extends PlannerGraph.Edge>
- Parameters:
context
- the contextnode
- the node to be renderedattributes
- the attributes of the node
-
renderEdge
protected void renderEdge(@Nonnull GraphExporter.ExporterContext context, boolean isDirected, @Nonnull N source, @Nonnull N target, @Nonnull Map<String,Attribute> attributes)
Description copied from class:GraphExporter
Render an edge. To be implemented by subclass.- Specified by:
renderEdge
in classGraphExporter<N extends PlannerGraph.Node,E extends PlannerGraph.Edge>
- Parameters:
context
- the contextisDirected
- true iff edge is directedsource
- the source node of the edgetarget
- the target node of the edgeattributes
- the attributes of the edge
-
renderClusters
protected void renderClusters(@Nonnull GraphExporter.ExporterContext context, @Nonnull Collection<GraphExporter.Cluster<N,E>> clusters)
Description copied from class:GraphExporter
Render all sub clusters in a given network.- Specified by:
renderClusters
in classGraphExporter<N extends PlannerGraph.Node,E extends PlannerGraph.Edge>
- Parameters:
context
- the context to useclusters
- the clusters on this level
-
renderClusters
protected void renderClusters(@Nonnull GraphExporter.ExporterContext context, @NonNull Set<N> currentNodes, @Nonnull Collection<GraphExporter.Cluster<N,E>> nestedClusters, @Nonnull String prefix, @Nonnull String indentation)
-
renderCluster
protected void renderCluster(@Nonnull GraphExporter.ExporterContext context, @Nonnull String clusterId, @Nonnull GraphExporter.Cluster<N,E> cluster, @Nonnull Map<String,Attribute> attributes, @Nonnull String indentation)
Render a sub cluster. To be implemented by subclass.- Parameters:
context
- the contextclusterId
- id of the cluster, can be used for naming purposescluster
- the cluster to be serializedattributes
- the attributes of the sub clusterindentation
- indentation
-
renderFooter
protected void renderFooter(@Nonnull GraphExporter.ExporterContext context)
Compute the footer.- Specified by:
renderFooter
in classGraphExporter<N extends PlannerGraph.Node,E extends PlannerGraph.Edge>
- Parameters:
context
- the context
-
getNodeLabel
@Nonnull public String getNodeLabel(@Nonnull Attribute name, @Nullable Attribute details, @Nonnull Map<String,Attribute> nodeAttributes)
-
-