Shoobx/python-graph

View on GitHub

Showing 41 of 66 total issues

Function maximum_flow has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
Open

def maximum_flow(graph, source, sink, caps = None):
    """
    Find a maximum flow and minimum cut of a directed graph by the Edmonds-Karp algorithm.

    @type graph: digraph
Severity: Minor
Found in core/pygraph/algorithms/minmax.py - About 5 hrs to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

File minmax.py has 373 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# Copyright (c) 2007-2009 Pedro Matiello <pmatiello@gmail.com>
#                         Peter Sagerson <peter.sagerson@gmail.com>
#                         Johannes Reinhardt <jreinhardt@ist-dein-freund.de>
#                         Rhys Ulerich <rhys.ulerich@gmail.com>
#                         Roy Smith <roy@panix.com>
Severity: Minor
Found in core/pygraph/algorithms/minmax.py - About 4 hrs to fix

    Function find_cycle has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
    Open

    def find_cycle(graph):
        """
        Find a cycle in the given graph.
        
        This function will return a list of nodes which form a cycle in the graph or an empty list if
    Severity: Minor
    Found in core/pygraph/algorithms/cycles.py - About 4 hrs to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Function __eq__ has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
    Open

        def __eq__(self, other):
            """
            Return whether this graph is equal to another one.
            
            @type other: graph, digraph
    Severity: Minor
    Found in core/pygraph/mixins/labeling.py - About 3 hrs to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Function cut_nodes has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
    Open

    def cut_nodes(graph):
        """
        Return the cut-nodes of the given graph.
        
        A cut node, or articulation point, is a node of a graph whose removal increases the number of
    Severity: Minor
    Found in core/pygraph/algorithms/accessibility.py - About 3 hrs to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Function read has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
    Open

    def read(string):
        """
        Read a graph from a string in Dot language and return it. Nodes and edges specified in the
        input will be added to the current graph.
        
    Severity: Minor
    Found in dot/pygraph/readwrite/dot.py - About 3 hrs to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Function write has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
    Open

    def write(G, weighted=False):
        """
        Return a string specifying the given graph in Dot language.
        
        @type  G: graph
    Severity: Minor
    Found in dot/pygraph/readwrite/dot.py - About 3 hrs to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Function __eq__ has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
    Open

        def __eq__(self, other):
            """
            Return whether this graph is equal to another one.
            
            @type other: graph, digraph
    Severity: Minor
    Found in core/pygraph/mixins/common.py - About 3 hrs to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Function cut_tree has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
    Open

    def cut_tree(igraph, caps = None):
        """
        Construct a Gomory-Hu cut tree by applying the algorithm of Gusfield.
    
        @type igraph: graph
    Severity: Minor
    Found in core/pygraph/algorithms/minmax.py - About 2 hrs to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Function optimize has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
    Open

        def optimize(self, graph):
            """
            Build a dictionary mapping each pair of nodes to a number (the distance between them).
            
            @type  graph: graph
    Severity: Minor
    Found in core/pygraph/algorithms/heuristics/euclidean.py - About 2 hrs to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Function __eq__ has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

        def __eq__(self, other):
            """
            Return whether this hypergraph is equal to another one.
            
            @type other: hypergraph
    Severity: Minor
    Found in core/pygraph/classes/hypergraph.py - About 2 hrs to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Function breadth_first_search has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

    def breadth_first_search(graph, root=None, filter=null()):
        """
        Breadth-first search.
    
        @type  graph: graph, digraph
    Severity: Minor
    Found in core/pygraph/algorithms/searching.py - About 2 hrs to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Function heuristic_search has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
    Open

    def heuristic_search(graph, start, goal, heuristic):
        """
        A* search algorithm.
        
        A set of heuristics is available under C{graph.algorithms.heuristics}. User-created heuristics
    Severity: Minor
    Found in core/pygraph/algorithms/minmax.py - About 2 hrs to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    hypergraph has 22 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class hypergraph (basegraph, common, labeling):
        """
        Hypergraph class.
        
        Hypergraphs are a generalization of graphs where an edge (called hyperedge) can connect more
    Severity: Minor
    Found in core/pygraph/classes/hypergraph.py - About 2 hrs to fix

      Function generate_hypergraph has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

      def generate_hypergraph(num_nodes, num_edges, r = 0):
          """
          Create a random hyper graph.
          
          @type  num_nodes: number
      Severity: Minor
      Found in core/pygraph/algorithms/generators.py - About 2 hrs to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Function critical_path has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

      def critical_path(graph):
          """
          Compute and return the critical path in an acyclic directed weighted graph.
          
          @attention: This function is only meaningful for directed weighted acyclic graphs
      Severity: Minor
      Found in core/pygraph/algorithms/critical.py - About 2 hrs to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Function read has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

      def read(string):
          """
          Read a graph from a XML document and return it. Nodes and edges specified in the input will
          be added to the current graph.
          
      Severity: Minor
      Found in core/pygraph/readwrite/markup.py - About 1 hr to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Function cut_value has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

      def cut_value(graph, flow, cut):
          """
          Calculate the value of a cut.
      
          @type graph: digraph
      Severity: Minor
      Found in core/pygraph/algorithms/minmax.py - About 1 hr to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Function transitive_edges has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

      def transitive_edges(graph):
          """
          Return a list of transitive edges.
          
          Example of transitivity within graphs: A -> B, B -> C, A ->  C
      Severity: Minor
      Found in core/pygraph/algorithms/critical.py - About 1 hr to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Function shortest_path_bellman_ford has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

      def shortest_path_bellman_ford(graph, source):
          """
          Return the shortest path distance between the source node and all other 
          nodes in the graph using Bellman-Ford's algorithm.
          
      Severity: Minor
      Found in core/pygraph/algorithms/minmax.py - About 1 hr to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Severity
      Category
      Status
      Source
      Language