Class GraphPrinter<T>

java.lang.Object
com.graphs.utils.graph.GraphPrinter<T>
Type Parameters:
T - the bounding type stored in given graphs.

public class GraphPrinter<T> extends Object
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 Details

    • GraphPrinter

      public GraphPrinter()
  • Method Details

    • printMessageIfConditionIsSatisfied

      private static void printMessageIfConditionIsSatisfied(boolean condition, String message)
      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

      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.
      Parameters:
      induces - condition to verify inducing subgraph of a graph by some set.
      baseMessage - message printed besides condition satisfaction.
      Since:
      1.0
    • printIsConditionalMessage

      private static void printIsConditionalMessage(boolean is, String baseMessage)
      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

      public void printWhenGraphIsNotNull(Graph<T> graph, String message)
      This method prints message if given graph is not null.
      Parameters:
      graph - a graph to check if it is not null
      message - message to print if given graph is not null
      Since:
      2.0
    • printWhenGraphIsEmpty

      public void printWhenGraphIsEmpty(Graph<T> graph, String message)
      This method prints message if given graph is empty.
      Parameters:
      graph - a graph to check if it is empty
      message - message to print if given graph is empty
      Since:
      2.0
    • printWhenGraphIsComplete

      public void printWhenGraphIsComplete(Graph<T> graph, String message)
      This method prints message if a given graph is complete.
      Parameters:
      graph - a graph to check if it is complete
      message - message to print if given graph is complete
      Since:
      2.0
    • printGraph

      public void printGraph(Graph<T> graph)
      This method prints a given graph structure.
      Parameters:
      graph - a graph to print
      Since:
      1.0
    • printMDS

      public void printMDS(Graph<T> graph)
      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

      public void printMCDS(Graph<T> graph)
      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

      public void printMIS(Graph<T> graph)
      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 given Collection 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 vertex
      t - new data to store in vertex given by its index.
      Returns:
      given graph
      Throws:
      NegativeVertexIndexException - if parameter type int < 0.
      NoSuchVertexIndexException - if this graph does not contain vertex with given int 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 given Collection contains negative number(s).
      NoSuchVertexIndexException - if Collection 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 any int < 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 any int < 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 given Collection contains negative number(s).
      NoSuchVertexIndexException - if Collection 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 given Collection contains negative number(s).
      NoSuchVertexIndexException - if Collection contains any indexes that could not be identified with any vertex of given graph.
      Since:
      1.0
    • printIsBipartite

      public void printIsBipartite(Graph<T> graph)
      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 given Collection contains negative number(s).
      NoSuchVertexIndexException - if Collection 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 given Collection contains negative number(s).
      NoSuchVertexIndexException - if Collection contains any indexes that could not be identified with any vertex of given graph.
      Since:
      1.0