Package com.graphs.utils.graph
Class GraphPrinter<T>
java.lang.Object
com.graphs.utils.graph.GraphPrinter<T>
- Type Parameters:
T
- the bounding type stored in given graphs.
This utility class is a printer for
Graph
.
Using this class, you can print graph structure and
useful information related to some methods of that class.- Since:
- 2.0
- Version:
- JDK 1.7
- Author:
- Ćukasz Malara
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprivate static void
printConditionalMessage
(boolean condition, String baseMessage, String ifTrue, String ifFalse) This method prints a conditional message as feedback of other methods.void
printDoInduceBipartiteSubGraph
(Graph<T> graph, Collection<Integer> vertices) This method prints a feedback message whether given subset as a parameter induces bipartite subgraph of given graph or it does not.private static void
printDoInduceConditionalMessage
(boolean induces, String baseMessage) This method prints a feedback message about satisfaction of inducing subgraph of a graph by some set.void
printDoInduceConnectedSubGraph
(Graph<T> graph, Collection<Integer> vertices) This method prints a feedback message whether given subset as a parameter induces connected subgraph of given graph or does not.void
printGraph
(Graph<T> graph) This method prints a given graph structure.printIfSetVertexData
(Graph<T> graph, int index, T t) This method prints a feedback message when set given vertex data of given vertex by its index of given graph and returns that graph.printIfVerticesAdded
(Graph<T> graph, Collection<Integer> vertices) This method prints a feedback message if vertices given as a parameter have been added to given graph and returns that graph.printIfVerticesConnected
(Graph<T> graph, int indexI, int indexJ) This method prints a feedback message if vertices given as a parameter of given graph have been connected and returns that graph.printIfVerticesDisconnected
(Graph<T> graph, int indexI, int indexJ) This method prints a feedback message if vertices given as a parameter of given graph have been disconnected and returns that graph.printIfVerticesRemoved
(Graph<T> graph, Collection<Integer> vertices) This method prints a feedback message if vertices given as a parameter have been removed from a given graph and returns that graph.void
printIsBipartite
(Graph<T> graph) This method prints a feedback message whether given graph is bipartite or is not.private static void
printIsConditionalMessage
(boolean is, String baseMessage) This method prints a feedback message about satisfaction if the type is as expected.void
printIsConnectedDominatingSet
(Graph<T> graph, Collection<Integer> vertices) This method prints a feedback message whether given subset as a parameter is a connected dominating set in given graph or is not.void
printIsIndependentSet
(Graph<T> graph, Collection<Integer> vertices) This method prints a feedback message whether given subset as a parameter is an independent set in given graph or is not.void
This method prints computed a minimal connected dominating set in a given graph.void
This method prints computed a minimal dominating set in a given graph.private static void
printMessageIfConditionIsSatisfied
(boolean condition, String message) This method prints a message if the condition is satisfied.void
This method prints computed a maximal independent set in a given graph.void
printWhenGraphIsComplete
(Graph<T> graph, String message) This method prints message if a given graph is complete.void
printWhenGraphIsEmpty
(Graph<T> graph, String message) This method prints message if given graph is empty.void
printWhenGraphIsNotNull
(Graph<T> graph, String message) This method prints message if given graph is not null.
-
Constructor Details
-
GraphPrinter
public GraphPrinter()
-
-
Method Details
-
printMessageIfConditionIsSatisfied
This method prints a message if the condition is satisfied.- Parameters:
condition
- condition to check its satisfaction.message
- message to print if condition is satisfied- Since:
- 2.0
-
printConditionalMessage
private static void printConditionalMessage(boolean condition, String baseMessage, String ifTrue, String ifFalse) This method prints a conditional message as feedback of other methods.- Parameters:
condition
- condition to verify its satisfaction to determine which message option should be printed in feedback.baseMessage
- message printed besides satisfaction of a condition.ifTrue
- message printed if condition is satisfied.ifFalse
- message printed if condition is unsatisfied.- Since:
- 1.0
-
printDoInduceConditionalMessage
This method prints a feedback message about satisfaction of inducing subgraph of a graph by some set.- Parameters:
induces
- condition to verify inducing subgraph of a graph by some set.baseMessage
- message printed besides condition satisfaction.- Since:
- 1.0
-
printIsConditionalMessage
This method prints a feedback message about satisfaction if the type is as expected.- Parameters:
is
- condition to verify if the type is as expected.baseMessage
- message printed beside condition satisfaction.- Since:
- 2.0
-
printWhenGraphIsNotNull
This method prints message if given graph is not null.- Parameters:
graph
- a graph to check if it is not nullmessage
- message to print if given graph is not null- Since:
- 2.0
-
printWhenGraphIsEmpty
This method prints message if given graph is empty.- Parameters:
graph
- a graph to check if it is emptymessage
- message to print if given graph is empty- Since:
- 2.0
-
printWhenGraphIsComplete
This method prints message if a given graph is complete.- Parameters:
graph
- a graph to check if it is completemessage
- message to print if given graph is complete- Since:
- 2.0
-
printGraph
This method prints a given graph structure.- Parameters:
graph
- a graph to print- Since:
- 1.0
-
printMDS
This method prints computed a minimal dominating set in a given graph.- Parameters:
graph
- a graph to compute a minimal dominating set for.- Since:
- 1.0
-
printMCDS
This method prints computed a minimal connected dominating set in a given graph.- Parameters:
graph
- a graph to compute a minimal connected dominating set for.- Since:
- 1.0
-
printMIS
This method prints computed a maximal independent set in a given graph.- Parameters:
graph
- a graph to compute a maximal independent set for.- Since:
- 1.0
-
printIfVerticesAdded
public Graph<T> printIfVerticesAdded(Graph<T> graph, Collection<Integer> vertices) throws NegativeVertexIndexException This method prints a feedback message if vertices given as a parameter have been added to given graph and returns that graph.- Parameters:
graph
- a graph to add vertices to.vertices
-Collection
of indexes of vertices to add to given graph.- Returns:
- given graph
- Throws:
NegativeVertexIndexException
- if givenCollection
contains negative number(s).- Since:
- 1.0
-
printIfSetVertexData
public Graph<T> printIfSetVertexData(Graph<T> graph, int index, T t) throws NoSuchVertexIndexException, NegativeVertexIndexException This method prints a feedback message when set given vertex data of given vertex by its index of given graph and returns that graph.- Parameters:
graph
- a graph to set new data in its vertex.index
- numerical index of vertext
- new data to store in vertex given by its index.- Returns:
- given graph
- Throws:
NegativeVertexIndexException
- if parameter typeint < 0
.NoSuchVertexIndexException
- if this graph does not contain vertex with givenint
index.- Since:
- 2.0
-
printIfVerticesRemoved
public Graph<T> printIfVerticesRemoved(Graph<T> graph, Collection<Integer> vertices) throws NegativeVertexIndexException, NoSuchVertexIndexException This method prints a feedback message if vertices given as a parameter have been removed from a given graph and returns that graph.- Parameters:
graph
- a graph to remove vertices from.vertices
-Collection
of a vertices indexes to remove from given graph.- Returns:
- given graph.
- Throws:
NegativeVertexIndexException
- if givenCollection
contains negative number(s).NoSuchVertexIndexException
- ifCollection
contains any indexes that could not be identified with any vertex of given graph.- Since:
- 1.0
-
printIfVerticesConnected
public Graph<T> printIfVerticesConnected(Graph<T> graph, int indexI, int indexJ) throws NegativeVertexIndexException, NoSuchVertexIndexException This method prints a feedback message if vertices given as a parameter of given graph have been connected and returns that graph.- Parameters:
graph
- a graph to connect vertices of.indexI
- numerical index of a vertex.indexJ
- numerical index of another vertex.- Returns:
- given graph.
- Throws:
NegativeVertexIndexException
- if anyint < 0
.NoSuchVertexIndexException
- if given graph does not contain either vertex with index given as a parameter.- Since:
- 1.0
-
printIfVerticesDisconnected
public Graph<T> printIfVerticesDisconnected(Graph<T> graph, int indexI, int indexJ) throws NegativeVertexIndexException, NoSuchVertexIndexException This method prints a feedback message if vertices given as a parameter of given graph have been disconnected and returns that graph.- Parameters:
graph
- a graph to disconnect vertices of.indexI
- numerical index of a vertex.indexJ
- numerical index of another vertex.- Returns:
- given graph.
- Throws:
NegativeVertexIndexException
- if anyint < 0
.NoSuchVertexIndexException
- if given graph does not contain either vertex with index given as a parameter.- Since:
- 1.0
-
printIsConnectedDominatingSet
public void printIsConnectedDominatingSet(Graph<T> graph, Collection<Integer> vertices) throws NegativeVertexIndexException, NoSuchVertexIndexException This method prints a feedback message whether given subset as a parameter is a connected dominating set in given graph or is not.- Parameters:
graph
- a graph to check if given vertices set is a dominating set in that graph.vertices
-Collection
of a vertices indexes to check if they form a connected dominating set in given graph.- Throws:
NegativeVertexIndexException
- if givenCollection
contains negative number(s).NoSuchVertexIndexException
- ifCollection
contains any indexes that could not be identified with any vertex of given graph.- Since:
- 1.0
-
printIsIndependentSet
public void printIsIndependentSet(Graph<T> graph, Collection<Integer> vertices) throws NegativeVertexIndexException, NoSuchVertexIndexException This method prints a feedback message whether given subset as a parameter is an independent set in given graph or is not.- Parameters:
graph
- a graph to check, if given vertices collection is an independent set in that graph.vertices
-Collection
of a vertices indexes to check if they form a connected dominating set in given graph.- Throws:
NegativeVertexIndexException
- if givenCollection
contains negative number(s).NoSuchVertexIndexException
- ifCollection
contains any indexes that could not be identified with any vertex of given graph.- Since:
- 1.0
-
printIsBipartite
This method prints a feedback message whether given graph is bipartite or is not.- Parameters:
graph
- a graph to check if it is bipartite- Since:
- 1.0
-
printDoInduceBipartiteSubGraph
public void printDoInduceBipartiteSubGraph(Graph<T> graph, Collection<Integer> vertices) throws NegativeVertexIndexException, NoSuchVertexIndexException This method prints a feedback message whether given subset as a parameter induces bipartite subgraph of given graph or it does not.- Parameters:
graph
- a graph to check, if given vertices collection is an independent set in that graph.vertices
-Collection
of a vertices indexes to check if they induce bipartite subgraph of given graph.- Throws:
NegativeVertexIndexException
- if givenCollection
contains negative number(s).NoSuchVertexIndexException
- ifCollection
contains any indexes that could not be identified with any vertex of given graph.- Since:
- 1.0
-
printDoInduceConnectedSubGraph
public void printDoInduceConnectedSubGraph(Graph<T> graph, Collection<Integer> vertices) throws NegativeVertexIndexException, NoSuchVertexIndexException This method prints a feedback message whether given subset as a parameter induces connected subgraph of given graph or does not.- Parameters:
graph
- a graph to check, if given vertices collection is an independent set in that graph.vertices
-Collection
of a vertices indexes to check if they induce connected subgraph of given graph.- Throws:
NegativeVertexIndexException
- if givenCollection
contains negative number(s).NoSuchVertexIndexException
- ifCollection
contains any indexes that could not be identified with any vertex of given graph.- Since:
- 1.0
-