Class DefaultGraphType

  • All Implemented Interfaces:
    Serializable, GraphType

    public class DefaultGraphType
    extends Object
    implements GraphType, Serializable
    Default implementation of the graph type.

    The graph type describes various properties of a graph such as whether it is directed, undirected or mixed, whether it contain self-loops (a self-loop is an edge where the source vertex is the same as the target vertex), whether it contain multiple (parallel) edges (multiple edges which connect the same pair of vertices) and whether it is weighted or not.

    The type of a graph can be queried on runtime using method Graph.getType(). This way, for example, an algorithm can have different behavior based on whether the input graph is directed or undirected, etc.

    Author:
    Dimitrios Michail
    See Also:
    Serialized Form
    • Method Detail

      • isDirected

        public boolean isDirected()
        Description copied from interface: GraphType
        Returns true if all edges of the graph are directed, false otherwise.
        Specified by:
        isDirected in interface GraphType
        Returns:
        true if all edges of the graph are directed, false otherwise
      • isUndirected

        public boolean isUndirected()
        Description copied from interface: GraphType
        Returns true if all edges of the graph are undirected, false otherwise.
        Specified by:
        isUndirected in interface GraphType
        Returns:
        true if all edges of the graph are undirected, false otherwise
      • isMixed

        public boolean isMixed()
        Description copied from interface: GraphType
        Returns true if the graph contain both directed and undirected edges, false otherwise.
        Specified by:
        isMixed in interface GraphType
        Returns:
        true if the graph contain both directed and undirected edges, false otherwise
      • isAllowingMultipleEdges

        public boolean isAllowingMultipleEdges()
        Description copied from interface: GraphType
        Returns true if and only if multiple (parallel) edges are allowed in this graph. The meaning of multiple edges is that there can be many edges going from vertex v1 to vertex v2.
        Specified by:
        isAllowingMultipleEdges in interface GraphType
        Returns:
        true if and only if multiple (parallel) edges are allowed.
      • isAllowingSelfLoops

        public boolean isAllowingSelfLoops()
        Description copied from interface: GraphType
        Returns true if and only if self-loops are allowed in this graph. A self loop is an edge that its source and target vertices are the same.
        Specified by:
        isAllowingSelfLoops in interface GraphType
        Returns:
        true if and only if graph self-loops are allowed.
      • isWeighted

        public boolean isWeighted()
        Description copied from interface: GraphType
        Returns true if and only if the graph supports edge weights.
        Specified by:
        isWeighted in interface GraphType
        Returns:
        true if the graph supports edge weights, false otherwise.
      • isAllowingCycles

        public boolean isAllowingCycles()
        Description copied from interface: GraphType
        Returns true if and only if cycles are allowed in this graph.
        Specified by:
        isAllowingCycles in interface GraphType
        Returns:
        true if and only if graph cycles are allowed.
      • isModifiable

        public boolean isModifiable()
        Description copied from interface: GraphType
        Returns true if the graph is modifiable, false otherwise.
        Specified by:
        isModifiable in interface GraphType
        Returns:
        true if the graph is modifiable, false otherwise
      • isSimple

        public boolean isSimple()
        Description copied from interface: GraphType
        Returns true if the graph is simple, false otherwise.
        Specified by:
        isSimple in interface GraphType
        Returns:
        true if the graph is simple, false otherwise
      • isPseudograph

        public boolean isPseudograph()
        Description copied from interface: GraphType
        Returns true if the graph is a pseudograph, false otherwise.
        Specified by:
        isPseudograph in interface GraphType
        Returns:
        true if the graph is a pseudograph, false otherwise
      • isMultigraph

        public boolean isMultigraph()
        Description copied from interface: GraphType
        Returns true if the graph is a multigraph, false otherwise.
        Specified by:
        isMultigraph in interface GraphType
        Returns:
        true if the graph is a multigraph, false otherwise
      • asDirected

        public GraphType asDirected()
        Description copied from interface: GraphType
        Create a directed variant of the current graph type.
        Specified by:
        asDirected in interface GraphType
        Returns:
        a directed variant of the current graph type
      • asUndirected

        public GraphType asUndirected()
        Description copied from interface: GraphType
        Create an undirected variant of the current graph type.
        Specified by:
        asUndirected in interface GraphType
        Returns:
        an undirected variant of the current graph type
      • asMixed

        public GraphType asMixed()
        Description copied from interface: GraphType
        Create a mixed variant of the current graph type.
        Specified by:
        asMixed in interface GraphType
        Returns:
        a mixed variant of the current graph type
      • asUnweighted

        public GraphType asUnweighted()
        Description copied from interface: GraphType
        Create an unweighted variant of the current graph type.
        Specified by:
        asUnweighted in interface GraphType
        Returns:
        an unweighted variant of the current graph type
      • asWeighted

        public GraphType asWeighted()
        Description copied from interface: GraphType
        Create a weighted variant of the current graph type.
        Specified by:
        asWeighted in interface GraphType
        Returns:
        a weighted variant of the current graph type
      • asModifiable

        public GraphType asModifiable()
        Description copied from interface: GraphType
        Create a modifiable variant of the current graph type.
        Specified by:
        asModifiable in interface GraphType
        Returns:
        a modifiable variant of the current graph type
      • asUnmodifiable

        public GraphType asUnmodifiable()
        Description copied from interface: GraphType
        Create an unmodifiable variant of the current graph type.
        Specified by:
        asUnmodifiable in interface GraphType
        Returns:
        a unmodifiable variant of the current graph type
      • simple

        public static DefaultGraphType simple()
        A simple graph type. An undirected graph for which at most one edge connects any two vertices, and self-loops are not permitted.
        Returns:
        a simple graph type
      • multigraph

        public static DefaultGraphType multigraph()
        A multigraph type. A non-simple undirected graph in which no self-loops are permitted, but multiple edges between any two vertices are.
        Returns:
        a multigraph type
      • pseudograph

        public static DefaultGraphType pseudograph()
        A pseudograph type. A non-simple undirected graph in which both graph self-loops and multiple edges are permitted.
        Returns:
        a pseudograph type
      • directedSimple

        public static DefaultGraphType directedSimple()
        A directed simple graph type. An undirected graph for which at most one edge connects any two vertices, and self-loops are not permitted.
        Returns:
        a directed simple graph type
      • directedMultigraph

        public static DefaultGraphType directedMultigraph()
        A directed multigraph type. A non-simple undirected graph in which no self-loops are permitted, but multiple edges between any two vertices are.
        Returns:
        a directed multigraph type
      • directedPseudograph

        public static DefaultGraphType directedPseudograph()
        A directed pseudograph type. A non-simple undirected graph in which both graph self-loops and multiple edges are permitted.
        Returns:
        a directed pseudograph type
      • mixed

        public static DefaultGraphType mixed()
        A mixed graph type. A graph having a set of undirected and a set of directed edges, which may contain self-loops and multiple edges are permitted.
        Returns:
        a mixed graph type
      • dag

        public static DefaultGraphType dag()
        A directed acyclic graph.
        Returns:
        a directed acyclic graph type