Skip to content
Snippets Groups Projects
test_gis_identify.py 176 KiB
Newer Older
  • Learn to ignore specific revisions
  • Pedro Magalhães's avatar
    Pedro Magalhães committed
    # imports
    
    # standard
    
    import random
    from math import isclose
    import uuid
    
    # local, external
    import osmnx as ox
    import networkx as nx
    from shapely.geometry import Point, LineString
    
    # local, internal
    
    import src.topupopt.data.gis.identify as gis_iden
    import src.topupopt.data.gis.osm as gis_osm
    
    # *****************************************************************************
    # *****************************************************************************
    
    
    Pedro Magalhães's avatar
    Pedro Magalhães committed
    class TestGisIdentify:
        # *************************************************************************
        # *************************************************************************
    
        def straight_path_validator(
    
    Pedro L. Magalhães's avatar
    Pedro L. Magalhães committed
            self,
            network: nx.MultiDiGraph,
            path: list,
            excluded_nodes: list,
            consider_reversed_edges: bool,
            ignore_self_loops: bool,
        ):
    
    Pedro Magalhães's avatar
    Pedro Magalhães committed
            # find out the unique nodes
            set_nodes = set(path)
            # at least three nodes
            assert len(path) >= 3
            # no repeated nodes unless they appear first and last
            for node in set_nodes:
                # count the nodes
                node_count = path.count(node)
                if node_count >= 3:
    
    pmag's avatar
    pmag committed
                    # the same node cannot appear three or more times
    
    Pedro Magalhães's avatar
    Pedro Magalhães committed
                    assert False
                elif node_count == 2:
                    # cycle: the first and last nodes must match
                    assert path[0] == path[-1] and path[0] == node
                    # cycle: make sure
            # no excluded nodes in the intermediate positions
            for node in excluded_nodes:
                assert node not in path[1:-1]
    
            # intermediate nodes can only have two neighbours
            for node_key in path[1:-1]:
    
    Pedro L. Magalhães's avatar
    Pedro L. Magalhães committed
                assert (
                    len(set(gis_iden.neighbours(network, node_key, ignore_self_loops=True)))
                    == 2
                )
    
            # end nodes need to have at least one neighbour, except in loops,
            # wherein they need to have two neighbours
            if path[0] == path[-1]:
                # end nodes in loops need to have at least two neighbours
    
    Pedro L. Magalhães's avatar
    Pedro L. Magalhães committed
                assert (
                    len(set(gis_iden.neighbours(network, path[0], ignore_self_loops=True)))
                    >= 2
                )
    
            else:
                # end nodes need to have at least one neighbour
    
    Pedro L. Magalhães's avatar
    Pedro L. Magalhães committed
                assert (
                    len(set(gis_iden.neighbours(network, path[0], ignore_self_loops=True)))
                    >= 1
                )
                assert (
                    len(set(gis_iden.neighbours(network, path[-1], ignore_self_loops=True)))
                    >= 1
                )
    
            # if ignore_self_loops=False, intermediate nodes cannot have self-loops
            if not ignore_self_loops:
                for node in path[1:-1]:
                    assert not network.has_edge(node, node)
                # if path[0] == path[-1]:
                #     # loop, applies to all nodes
                #     for node in path:
                #         assert not network.has_edge(node, node)
                # else:
                #     # not a loop, applies only to intermediate nodes
                #     for node in path[1:-1]:
                #         assert not network.has_edge(node, node)
    
    pmag's avatar
    pmag committed
            # make sure it qualifies as a path
            assert gis_iden.is_node_path(
    
    Pedro L. Magalhães's avatar
    Pedro L. Magalhães committed
                network, path, consider_reversed_edges=consider_reversed_edges
            )
    
            # make sure it is a straight path
            assert gis_iden.is_path_straight(
    
    Pedro L. Magalhães's avatar
    Pedro L. Magalhães committed
                network,
                path,
    
                consider_reversed_edges=consider_reversed_edges,
    
    Pedro L. Magalhães's avatar
    Pedro L. Magalhães committed
                ignore_self_loops=ignore_self_loops,
            )
    
    
        # *************************************************************************
        # *************************************************************************
    
        def test_finding_simplifiable_paths_osmnx(self):
            # network should be a OSM-nx formatted graph
            network = ox.graph_from_point(
    
    Pedro L. Magalhães's avatar
    Pedro L. Magalhães committed
                (55.71654, 9.11728),
                network_type="drive",
    
                custom_filter='["highway"~"residential|tertiary|unclassified|service"]',
    
    Pedro L. Magalhães's avatar
    Pedro L. Magalhães committed
                truncate_by_edge=True,
            )
    
    
            # *********************************************************************
            # *********************************************************************
    
            consider_reversed_edges = False
            ignore_self_loops = False
    
            # paths
            paths = gis_iden.find_simplifiable_paths(
    
    Pedro L. Magalhães's avatar
    Pedro L. Magalhães committed
                network,
    
                excluded_nodes=[],
                consider_reversed_edges=consider_reversed_edges,
    
    Pedro L. Magalhães's avatar
    Pedro L. Magalhães committed
                ignore_self_loops=ignore_self_loops,
            )
    
            # verify the paths
            for path in paths:
                self.straight_path_validator(
    
    Pedro L. Magalhães's avatar
    Pedro L. Magalhães committed
                    network,
                    path,
                    excluded_nodes=[],
    
                    consider_reversed_edges=consider_reversed_edges,
    
    Pedro L. Magalhães's avatar
    Pedro L. Magalhães committed
                    ignore_self_loops=ignore_self_loops,
                )
    
    
            # *********************************************************************
            # *********************************************************************
    
            consider_reversed_edges = False
            ignore_self_loops = True
    
            # paths
            paths = gis_iden.find_simplifiable_paths(
    
    Pedro L. Magalhães's avatar
    Pedro L. Magalhães committed
                network,
    
                excluded_nodes=[],
                consider_reversed_edges=consider_reversed_edges,
    
    Pedro L. Magalhães's avatar
    Pedro L. Magalhães committed
                ignore_self_loops=ignore_self_loops,
            )
    
            # verify the paths
            for path in paths:
                self.straight_path_validator(
    
    Pedro L. Magalhães's avatar
    Pedro L. Magalhães committed
                    network,
                    path,
                    excluded_nodes=[],
    
                    consider_reversed_edges=consider_reversed_edges,
    
    Pedro L. Magalhães's avatar
    Pedro L. Magalhães committed
                    ignore_self_loops=ignore_self_loops,
                )
    
    
            # *********************************************************************
            # *********************************************************************
    
            consider_reversed_edges = True
            ignore_self_loops = False
    
            # paths
            paths = gis_iden.find_simplifiable_paths(
    
    Pedro L. Magalhães's avatar
    Pedro L. Magalhães committed
                network,
    
                excluded_nodes=[],
                consider_reversed_edges=consider_reversed_edges,
    
    Pedro L. Magalhães's avatar
    Pedro L. Magalhães committed
                ignore_self_loops=ignore_self_loops,
            )
    
            # verify the paths
            for path in paths:
                self.straight_path_validator(
    
    Pedro L. Magalhães's avatar
    Pedro L. Magalhães committed
                    network,
                    path,
                    excluded_nodes=[],
    
                    consider_reversed_edges=consider_reversed_edges,
    
    Pedro L. Magalhães's avatar
    Pedro L. Magalhães committed
                    ignore_self_loops=ignore_self_loops,
                )
    
    
            # *********************************************************************
            # *********************************************************************
    
            consider_reversed_edges = True
            ignore_self_loops = True
    
            # paths
            paths = gis_iden.find_simplifiable_paths(
    
    Pedro L. Magalhães's avatar
    Pedro L. Magalhães committed
                network,
    
                excluded_nodes=[],
                consider_reversed_edges=consider_reversed_edges,
    
    Pedro L. Magalhães's avatar
    Pedro L. Magalhães committed
                ignore_self_loops=ignore_self_loops,
            )
    
            # verify the paths
            for path in paths:
                self.straight_path_validator(
    
    Pedro L. Magalhães's avatar
    Pedro L. Magalhães committed
                    network,
                    path,
                    excluded_nodes=[],
    
                    consider_reversed_edges=consider_reversed_edges,
    
    Pedro L. Magalhães's avatar
    Pedro L. Magalhães committed
                    ignore_self_loops=ignore_self_loops,
                )
    
            # *********************************************************************
            # *********************************************************************
    
    pmag's avatar
    pmag committed
    
    
    Pedro Magalhães's avatar
    Pedro Magalhães committed
        # *************************************************************************
        # *************************************************************************
    
    pmag's avatar
    pmag committed
        def test_find_straight_path_empty_graph(self):
            # test variations:
            # 1) excluded nodes
            # 2) self loops
            # 3) reversed edges
    
    pmag's avatar
    pmag committed
            # *********************************************************************
            # *********************************************************************
    
    pmag's avatar
    pmag committed
            # network with a two edge path
    
    Pedro Magalhães's avatar
    Pedro Magalhães committed
            network = nx.MultiDiGraph()
    
    pmag's avatar
    pmag committed
            # no reversed edges, no self loops, no excluded nodes
            consider_reversed_edges = False
            ignore_self_loops = False
    
    Pedro Magalhães's avatar
    Pedro Magalhães committed
            excluded_nodes = []
    
    pmag's avatar
    pmag committed
            # test path validator with non-path
            error_raised = False
            try:
    
                assert not self.straight_path_validator(
    
    Pedro L. Magalhães's avatar
    Pedro L. Magalhães committed
                    network,
                    [1, 1, 1],
                    excluded_nodes,
    
                    consider_reversed_edges=consider_reversed_edges,
    
    Pedro L. Magalhães's avatar
    Pedro L. Magalhães committed
                    ignore_self_loops=ignore_self_loops,
                )
    
    pmag's avatar
    pmag committed
            except AssertionError:
                error_raised = True
    
    Pedro L. Magalhães's avatar
    Pedro L. Magalhães committed
            assert error_raised
    
    
    pmag's avatar
    pmag committed
            straight_paths = gis_iden.find_simplifiable_paths(
    
    Pedro L. Magalhães's avatar
    Pedro L. Magalhães committed
                network,
    
    Pedro Magalhães's avatar
    Pedro Magalhães committed
                excluded_nodes,
    
    pmag's avatar
    pmag committed
                consider_reversed_edges=consider_reversed_edges,
    
    Pedro L. Magalhães's avatar
    Pedro L. Magalhães committed
                ignore_self_loops=ignore_self_loops,
            )
    
    Pedro Magalhães's avatar
    Pedro Magalhães committed
            true_straight_paths = []
            assert len(straight_paths) == len(true_straight_paths)
            assert len(straight_paths) == 0
    
    Pedro Magalhães's avatar
    Pedro Magalhães committed
            # *********************************************************************
    
    pmag's avatar
    pmag committed
            # *********************************************************************
    
    pmag's avatar
    pmag committed
            # no reversed edges, no self loops, no excluded nodes
            consider_reversed_edges = False
            ignore_self_loops = True
    
    Pedro Magalhães's avatar
    Pedro Magalhães committed
            excluded_nodes = []
    
    pmag's avatar
    pmag committed
            straight_paths = gis_iden.find_simplifiable_paths(
    
    Pedro L. Magalhães's avatar
    Pedro L. Magalhães committed
                network,
    
    Pedro Magalhães's avatar
    Pedro Magalhães committed
                excluded_nodes,
    
    pmag's avatar
    pmag committed
                consider_reversed_edges=consider_reversed_edges,
    
    Pedro L. Magalhães's avatar
    Pedro L. Magalhães committed
                ignore_self_loops=ignore_self_loops,
            )
    
    pmag's avatar
    pmag committed
            true_straight_paths = []
    
    Pedro Magalhães's avatar
    Pedro Magalhães committed
            assert len(straight_paths) == len(true_straight_paths)
    
    pmag's avatar
    pmag committed
            assert len(straight_paths) == 0
    
    Pedro Magalhães's avatar
    Pedro Magalhães committed
            # *********************************************************************
    
    pmag's avatar
    pmag committed
            # *********************************************************************
    
    pmag's avatar
    pmag committed
            # network with a two edge path
    
    Pedro Magalhães's avatar
    Pedro Magalhães committed
            network = nx.MultiDiGraph()
    
    pmag's avatar
    pmag committed
            # no reversed edges, no self loops, no excluded nodes
            consider_reversed_edges = True
            ignore_self_loops = False
    
    Pedro Magalhães's avatar
    Pedro Magalhães committed
            excluded_nodes = []
    
    pmag's avatar
    pmag committed
            straight_paths = gis_iden.find_simplifiable_paths(
    
    Pedro L. Magalhães's avatar
    Pedro L. Magalhães committed
                network,
    
    Pedro Magalhães's avatar
    Pedro Magalhães committed
                excluded_nodes,
    
    pmag's avatar
    pmag committed
                consider_reversed_edges=consider_reversed_edges,
    
    Pedro L. Magalhães's avatar
    Pedro L. Magalhães committed
                ignore_self_loops=ignore_self_loops,
            )
    
    pmag's avatar
    pmag committed
            true_straight_paths = []
    
    Pedro Magalhães's avatar
    Pedro Magalhães committed
            assert len(straight_paths) == len(true_straight_paths)
    
    pmag's avatar
    pmag committed
            assert len(straight_paths) == 0
    
    pmag's avatar
    pmag committed
            # *********************************************************************
            # *********************************************************************
    
    pmag's avatar
    pmag committed
            # network with a two edge path
    
    Pedro Magalhães's avatar
    Pedro Magalhães committed
            network = nx.MultiDiGraph()
    
    pmag's avatar
    pmag committed
            # no reversed edges, no self loops, no excluded nodes
            consider_reversed_edges = True
            ignore_self_loops = True
            excluded_nodes = []
    
    pmag's avatar
    pmag committed
            straight_paths = gis_iden.find_simplifiable_paths(
    
    Pedro L. Magalhães's avatar
    Pedro L. Magalhães committed
                network,
    
    Pedro Magalhães's avatar
    Pedro Magalhães committed
                excluded_nodes,
    
    pmag's avatar
    pmag committed
                consider_reversed_edges=consider_reversed_edges,
    
    Pedro L. Magalhães's avatar
    Pedro L. Magalhães committed
                ignore_self_loops=ignore_self_loops,
            )
    
    pmag's avatar
    pmag committed
            true_straight_paths = []
    
    Pedro Magalhães's avatar
    Pedro Magalhães committed
            assert len(straight_paths) == len(true_straight_paths)
    
    pmag's avatar
    pmag committed
            assert len(straight_paths) == 0
    
    Pedro L. Magalhães's avatar
    Pedro L. Magalhães committed
    
            # *********************************************************************
    
    pmag's avatar
    pmag committed
            # *********************************************************************
    
    pmag's avatar
    pmag committed
            # enhance test coverage
    
    pmag's avatar
    pmag committed
            # add single node
            network.add_node(0)
    
            path = gis_iden._find_path_direction_insensitive(network, [], 0, False)
    
    pmag's avatar
    pmag committed
            assert type(path) == list
            assert len(path) == 1
            assert repr(path) == repr([0])
    
    pmag's avatar
    pmag committed
        # *************************************************************************
        # *************************************************************************
    
    pmag's avatar
    pmag committed
        def test_find_one_edge_path(self):
            # *********************************************************************
            # *********************************************************************
    
    pmag's avatar
    pmag committed
            # network with a two edge path
    
    Pedro Magalhães's avatar
    Pedro Magalhães committed
            network = nx.MultiDiGraph()
    
    Pedro L. Magalhães's avatar
    Pedro L. Magalhães committed
            network.add_edges_from([(0, 1, 0)])
    
    
    pmag's avatar
    pmag committed
            # *********************************************************************
            # *********************************************************************
    
    pmag's avatar
    pmag committed
            # do not consider reversed edges
            consider_reversed_edges = False
    
    pmag's avatar
    pmag committed
            # *********************************************************************
            # *********************************************************************
    
    pmag's avatar
    pmag committed
            # no reversed edges, no self loops, no excluded nodes
            ignore_self_loops = False
            excluded_nodes = []
    
    pmag's avatar
    pmag committed
            straight_paths = gis_iden.find_simplifiable_paths(
    
    Pedro L. Magalhães's avatar
    Pedro L. Magalhães committed
                network,
    
    Pedro Magalhães's avatar
    Pedro Magalhães committed
                excluded_nodes,
    
    pmag's avatar
    pmag committed
                consider_reversed_edges=consider_reversed_edges,
    
    Pedro L. Magalhães's avatar
    Pedro L. Magalhães committed
                ignore_self_loops=ignore_self_loops,
            )
    
    pmag's avatar
    pmag committed
            true_straight_paths = []
    
    Pedro Magalhães's avatar
    Pedro Magalhães committed
            assert len(straight_paths) == len(true_straight_paths)
    
    pmag's avatar
    pmag committed
            # *********************************************************************
            # *********************************************************************
    
    pmag's avatar
    pmag committed
            # no reversed edges, allow self loops, no excluded nodes
            ignore_self_loops = True
            excluded_nodes = []
    
    pmag's avatar
    pmag committed
            straight_paths = gis_iden.find_simplifiable_paths(
    
    Pedro L. Magalhães's avatar
    Pedro L. Magalhães committed
                network,
    
    pmag's avatar
    pmag committed
                excluded_nodes,
                consider_reversed_edges=consider_reversed_edges,
    
    Pedro L. Magalhães's avatar
    Pedro L. Magalhães committed
                ignore_self_loops=ignore_self_loops,
            )
    
    pmag's avatar
    pmag committed
            true_straight_paths = []
            assert len(straight_paths) == len(true_straight_paths)
    
    pmag's avatar
    pmag committed
            # *********************************************************************
            # *********************************************************************
    
    pmag's avatar
    pmag committed
            # do not allow reversed edges, no self loops, excluded the middle node
            ignore_self_loops = False
            excluded_nodes = [1]
    
    pmag's avatar
    pmag committed
            straight_paths = gis_iden.find_simplifiable_paths(
    
    Pedro L. Magalhães's avatar
    Pedro L. Magalhães committed
                network,
    
    pmag's avatar
    pmag committed
                excluded_nodes,
                consider_reversed_edges=consider_reversed_edges,
    
    Pedro L. Magalhães's avatar
    Pedro L. Magalhães committed
                ignore_self_loops=ignore_self_loops,
            )
    
    pmag's avatar
    pmag committed
            true_straight_paths = []
            assert len(straight_paths) == len(true_straight_paths)
    
    pmag's avatar
    pmag committed
            # *********************************************************************
            # *********************************************************************
    
    pmag's avatar
    pmag committed
            # do not allow reversed edges, no self loops, excluded the start node
            ignore_self_loops = False
            excluded_nodes = [0]
    
    pmag's avatar
    pmag committed
            straight_paths = gis_iden.find_simplifiable_paths(
    
    Pedro L. Magalhães's avatar
    Pedro L. Magalhães committed
                network,
    
    pmag's avatar
    pmag committed
                excluded_nodes,
                consider_reversed_edges=consider_reversed_edges,
    
    Pedro L. Magalhães's avatar
    Pedro L. Magalhães committed
                ignore_self_loops=ignore_self_loops,
            )
    
    pmag's avatar
    pmag committed
            true_straight_paths = []
            assert len(straight_paths) == len(true_straight_paths)
    
    pmag's avatar
    pmag committed
            # *********************************************************************
            # *********************************************************************
    
    pmag's avatar
    pmag committed
            # do not allow reversed edges, no self loops, excluded the end node
            ignore_self_loops = False
    
    Pedro Magalhães's avatar
    Pedro Magalhães committed
            excluded_nodes = [2]
    
    pmag's avatar
    pmag committed
            straight_paths = gis_iden.find_simplifiable_paths(
    
    Pedro L. Magalhães's avatar
    Pedro L. Magalhães committed
                network,
    
    Pedro Magalhães's avatar
    Pedro Magalhães committed
                excluded_nodes,
    
    pmag's avatar
    pmag committed
                consider_reversed_edges=consider_reversed_edges,
    
    Pedro L. Magalhães's avatar
    Pedro L. Magalhães committed
                ignore_self_loops=ignore_self_loops,
            )
    
    pmag's avatar
    pmag committed
            true_straight_paths = []
    
    Pedro Magalhães's avatar
    Pedro Magalhães committed
            assert len(straight_paths) == len(true_straight_paths)
    
    pmag's avatar
    pmag committed
            # *********************************************************************
            # *********************************************************************
    
    pmag's avatar
    pmag committed
            # consider reversed edges
            consider_reversed_edges = True
    
    pmag's avatar
    pmag committed
            # *********************************************************************
            # *********************************************************************
    
    pmag's avatar
    pmag committed
            # allow reversed edges, allow self loops, no excluded nodes
            ignore_self_loops = True
            excluded_nodes = []
    
    pmag's avatar
    pmag committed
            straight_paths = gis_iden.find_simplifiable_paths(
    
    Pedro L. Magalhães's avatar
    Pedro L. Magalhães committed
                network,
    
    pmag's avatar
    pmag committed
                excluded_nodes,
                consider_reversed_edges=consider_reversed_edges,
    
    Pedro L. Magalhães's avatar
    Pedro L. Magalhães committed
                ignore_self_loops=ignore_self_loops,
            )
    
    pmag's avatar
    pmag committed
            true_straight_paths = []
            assert len(straight_paths) == len(true_straight_paths)
    
    pmag's avatar
    pmag committed
            # *********************************************************************
            # *********************************************************************
    
    pmag's avatar
    pmag committed
            # allow reversed edges, no self loops, no excluded nodes
            ignore_self_loops = False
            excluded_nodes = []
    
    pmag's avatar
    pmag committed
            straight_paths = gis_iden.find_simplifiable_paths(
    
    Pedro L. Magalhães's avatar
    Pedro L. Magalhães committed
                network,
    
    pmag's avatar
    pmag committed
                excluded_nodes,
                consider_reversed_edges=consider_reversed_edges,
    
    Pedro L. Magalhães's avatar
    Pedro L. Magalhães committed
                ignore_self_loops=ignore_self_loops,
            )
    
    pmag's avatar
    pmag committed
            true_straight_paths = []
            assert len(straight_paths) == len(true_straight_paths)
    
    pmag's avatar
    pmag committed
            # *********************************************************************
            # *********************************************************************
    
    pmag's avatar
    pmag committed
            # allow reversed edges, no self loops, excluded the middle node
            ignore_self_loops = False
            excluded_nodes = [1]
    
    pmag's avatar
    pmag committed
            straight_paths = gis_iden.find_simplifiable_paths(
    
    Pedro L. Magalhães's avatar
    Pedro L. Magalhães committed
                network,
    
    pmag's avatar
    pmag committed
                excluded_nodes,
                consider_reversed_edges=consider_reversed_edges,
    
    Pedro L. Magalhães's avatar
    Pedro L. Magalhães committed
                ignore_self_loops=ignore_self_loops,
            )
    
    pmag's avatar
    pmag committed
            true_straight_paths = []
            assert len(straight_paths) == len(true_straight_paths)
    
    pmag's avatar
    pmag committed
            # *********************************************************************
            # *********************************************************************
    
    pmag's avatar
    pmag committed
            # allow reversed edges, no self loops, excluded the start node
            ignore_self_loops = False
            excluded_nodes = [0]
    
    pmag's avatar
    pmag committed
            straight_paths = gis_iden.find_simplifiable_paths(
    
    Pedro L. Magalhães's avatar
    Pedro L. Magalhães committed
                network,
    
    pmag's avatar
    pmag committed
                excluded_nodes,
                consider_reversed_edges=consider_reversed_edges,
    
    Pedro L. Magalhães's avatar
    Pedro L. Magalhães committed
                ignore_self_loops=ignore_self_loops,
            )
    
    pmag's avatar
    pmag committed
            true_straight_paths = []
            assert len(straight_paths) == len(true_straight_paths)
    
    pmag's avatar
    pmag committed
            # *********************************************************************
            # *********************************************************************
    
    pmag's avatar
    pmag committed
            # allow reversed edges, no self loops, excluded the end node
            ignore_self_loops = False
    
    Pedro Magalhães's avatar
    Pedro Magalhães committed
            excluded_nodes = [2]
    
    pmag's avatar
    pmag committed
            straight_paths = gis_iden.find_simplifiable_paths(
    
    Pedro L. Magalhães's avatar
    Pedro L. Magalhães committed
                network,
    
    Pedro Magalhães's avatar
    Pedro Magalhães committed
                excluded_nodes,
    
    pmag's avatar
    pmag committed
                consider_reversed_edges=consider_reversed_edges,
    
    Pedro L. Magalhães's avatar
    Pedro L. Magalhães committed
                ignore_self_loops=ignore_self_loops,
            )
    
    pmag's avatar
    pmag committed
            true_straight_paths = []
    
    Pedro Magalhães's avatar
    Pedro Magalhães committed
            assert len(straight_paths) == len(true_straight_paths)
    
    pmag's avatar
    pmag committed
            # *********************************************************************
            # *********************************************************************
    
    pmag's avatar
    pmag committed
        # *************************************************************************
        # *************************************************************************
    
    pmag's avatar
    pmag committed
        def test_find_one_edge_path_w_reversed_edge(self):
            # *********************************************************************
            # *********************************************************************
    
    pmag's avatar
    pmag committed
            # network with a two edge path
    
    Pedro Magalhães's avatar
    Pedro Magalhães committed
            network = nx.MultiDiGraph()
    
    Pedro L. Magalhães's avatar
    Pedro L. Magalhães committed
            network.add_edges_from([(0, 1, 0), (1, 0, 0)])
    
    
    pmag's avatar
    pmag committed
            # *********************************************************************
            # *********************************************************************
    
    pmag's avatar
    pmag committed
            # do not consider reversed edges
            consider_reversed_edges = False
    
    pmag's avatar
    pmag committed
            # *********************************************************************
            # *********************************************************************
    
    pmag's avatar
    pmag committed
            # no reversed edges, no self loops, no excluded nodes
            ignore_self_loops = False
            excluded_nodes = []
    
    pmag's avatar
    pmag committed
            straight_paths = gis_iden.find_simplifiable_paths(
    
    Pedro L. Magalhães's avatar
    Pedro L. Magalhães committed
                network,
    
    pmag's avatar
    pmag committed
                excluded_nodes,
                consider_reversed_edges=consider_reversed_edges,
    
    Pedro L. Magalhães's avatar
    Pedro L. Magalhães committed
                ignore_self_loops=ignore_self_loops,
            )
    
    pmag's avatar
    pmag committed
            true_straight_paths = []
            assert len(straight_paths) == len(true_straight_paths)
    
    pmag's avatar
    pmag committed
            # *********************************************************************
            # *********************************************************************
    
    pmag's avatar
    pmag committed
            # no reversed edges, allow self loops, no excluded nodes
            ignore_self_loops = True
            excluded_nodes = []
    
    pmag's avatar
    pmag committed
            straight_paths = gis_iden.find_simplifiable_paths(
    
    Pedro L. Magalhães's avatar
    Pedro L. Magalhães committed
                network,
    
    pmag's avatar
    pmag committed
                excluded_nodes,
                consider_reversed_edges=consider_reversed_edges,
    
    Pedro L. Magalhães's avatar
    Pedro L. Magalhães committed
                ignore_self_loops=ignore_self_loops,
            )
    
    pmag's avatar
    pmag committed
            true_straight_paths = []
            assert len(straight_paths) == len(true_straight_paths)
    
    pmag's avatar
    pmag committed
            # *********************************************************************
            # *********************************************************************
    
    pmag's avatar
    pmag committed
            # do not allow reversed edges, no self loops, excluded the middle node
            ignore_self_loops = False
            excluded_nodes = [1]
    
    pmag's avatar
    pmag committed
            straight_paths = gis_iden.find_simplifiable_paths(
    
    Pedro L. Magalhães's avatar
    Pedro L. Magalhães committed
                network,
    
    pmag's avatar
    pmag committed
                excluded_nodes,
                consider_reversed_edges=consider_reversed_edges,
    
    Pedro L. Magalhães's avatar
    Pedro L. Magalhães committed
                ignore_self_loops=ignore_self_loops,
            )
    
    pmag's avatar
    pmag committed
            true_straight_paths = []
            assert len(straight_paths) == len(true_straight_paths)
    
    pmag's avatar
    pmag committed
            # *********************************************************************
            # *********************************************************************
    
    pmag's avatar
    pmag committed
            # do not allow reversed edges, no self loops, excluded the start node
            ignore_self_loops = False
            excluded_nodes = [0]
    
    pmag's avatar
    pmag committed
            straight_paths = gis_iden.find_simplifiable_paths(
    
    Pedro L. Magalhães's avatar
    Pedro L. Magalhães committed
                network,
    
    pmag's avatar
    pmag committed
                excluded_nodes,
                consider_reversed_edges=consider_reversed_edges,
    
    Pedro L. Magalhães's avatar
    Pedro L. Magalhães committed
                ignore_self_loops=ignore_self_loops,
            )
    
    pmag's avatar
    pmag committed
            true_straight_paths = []
            assert len(straight_paths) == len(true_straight_paths)
    
    pmag's avatar
    pmag committed
            # *********************************************************************
            # *********************************************************************
    
    pmag's avatar
    pmag committed
            # do not allow reversed edges, no self loops, excluded the end node
            ignore_self_loops = False
            excluded_nodes = [2]
    
    pmag's avatar
    pmag committed
            straight_paths = gis_iden.find_simplifiable_paths(
    
    Pedro L. Magalhães's avatar
    Pedro L. Magalhães committed
                network,
    
    pmag's avatar
    pmag committed
                excluded_nodes,
                consider_reversed_edges=consider_reversed_edges,
    
    Pedro L. Magalhães's avatar
    Pedro L. Magalhães committed
                ignore_self_loops=ignore_self_loops,
            )
    
    pmag's avatar
    pmag committed
            true_straight_paths = []
            assert len(straight_paths) == len(true_straight_paths)
    
    pmag's avatar
    pmag committed
            # *********************************************************************
            # *********************************************************************
    
    pmag's avatar
    pmag committed
            # consider reversed edges
            consider_reversed_edges = True
    
    pmag's avatar
    pmag committed
            # *********************************************************************
            # *********************************************************************
    
    pmag's avatar
    pmag committed
            # allow reversed edges, allow self loops, no excluded nodes
            ignore_self_loops = True
            excluded_nodes = []
    
    pmag's avatar
    pmag committed
            straight_paths = gis_iden.find_simplifiable_paths(
    
    Pedro L. Magalhães's avatar
    Pedro L. Magalhães committed
                network,
    
    pmag's avatar
    pmag committed
                excluded_nodes,
                consider_reversed_edges=consider_reversed_edges,
    
    Pedro L. Magalhães's avatar
    Pedro L. Magalhães committed
                ignore_self_loops=ignore_self_loops,
            )
    
    pmag's avatar
    pmag committed
            true_straight_paths = []
            assert len(straight_paths) == len(true_straight_paths)
    
    pmag's avatar
    pmag committed
            # *********************************************************************
            # *********************************************************************
    
    pmag's avatar
    pmag committed
            # allow reversed edges, no self loops, no excluded nodes
            ignore_self_loops = False
            excluded_nodes = []
    
    pmag's avatar
    pmag committed
            straight_paths = gis_iden.find_simplifiable_paths(
    
    Pedro L. Magalhães's avatar
    Pedro L. Magalhães committed
                network,
    
    pmag's avatar
    pmag committed
                excluded_nodes,
                consider_reversed_edges=consider_reversed_edges,
    
    Pedro L. Magalhães's avatar
    Pedro L. Magalhães committed
                ignore_self_loops=ignore_self_loops,
            )
    
    pmag's avatar
    pmag committed
            true_straight_paths = []
            assert len(straight_paths) == len(true_straight_paths)
    
    pmag's avatar
    pmag committed
            # *********************************************************************
            # *********************************************************************
    
    pmag's avatar
    pmag committed
            # allow reversed edges, no self loops, excluded the middle node
            ignore_self_loops = False
            excluded_nodes = [1]
    
    pmag's avatar
    pmag committed
            straight_paths = gis_iden.find_simplifiable_paths(
    
    Pedro L. Magalhães's avatar
    Pedro L. Magalhães committed
                network,
    
    pmag's avatar
    pmag committed
                excluded_nodes,
                consider_reversed_edges=consider_reversed_edges,
    
    Pedro L. Magalhães's avatar
    Pedro L. Magalhães committed
                ignore_self_loops=ignore_self_loops,
            )
    
    pmag's avatar
    pmag committed
            true_straight_paths = []
            assert len(straight_paths) == len(true_straight_paths)
    
    pmag's avatar
    pmag committed
            # *********************************************************************
            # *********************************************************************
    
    pmag's avatar
    pmag committed
            # allow reversed edges, no self loops, excluded the start node
            ignore_self_loops = False
            excluded_nodes = [0]
    
    pmag's avatar
    pmag committed
            straight_paths = gis_iden.find_simplifiable_paths(
    
    Pedro L. Magalhães's avatar
    Pedro L. Magalhães committed
                network,
    
    pmag's avatar
    pmag committed
                excluded_nodes,
                consider_reversed_edges=consider_reversed_edges,
    
    Pedro L. Magalhães's avatar
    Pedro L. Magalhães committed
                ignore_self_loops=ignore_self_loops,
            )
    
    pmag's avatar
    pmag committed
            true_straight_paths = []
            assert len(straight_paths) == len(true_straight_paths)
    
    pmag's avatar
    pmag committed
            # *********************************************************************
            # *********************************************************************
    
    pmag's avatar
    pmag committed
            # allow reversed edges, no self loops, excluded the end node
            ignore_self_loops = False
            excluded_nodes = [2]
    
    pmag's avatar
    pmag committed
            straight_paths = gis_iden.find_simplifiable_paths(
    
    Pedro L. Magalhães's avatar
    Pedro L. Magalhães committed
                network,
    
    pmag's avatar
    pmag committed
                excluded_nodes,
                consider_reversed_edges=consider_reversed_edges,
    
    Pedro L. Magalhães's avatar
    Pedro L. Magalhães committed
                ignore_self_loops=ignore_self_loops,
            )
    
    pmag's avatar
    pmag committed
            true_straight_paths = []
            assert len(straight_paths) == len(true_straight_paths)
    
    pmag's avatar
    pmag committed
            # *********************************************************************
            # *********************************************************************
    
        # *************************************************************************
        # *************************************************************************
    
    pmag's avatar
    pmag committed
        def test_find_simple_straight_path(self):
            # *********************************************************************
            # *********************************************************************
    
    pmag's avatar
    pmag committed
            # network with a two edge path
            network = nx.MultiDiGraph()
    
    Pedro L. Magalhães's avatar
    Pedro L. Magalhães committed
            network.add_edges_from([(0, 1, 0), (1, 2, 0)])
    
    
    pmag's avatar
    pmag committed
            # *********************************************************************
            # *********************************************************************
    
    pmag's avatar
    pmag committed
            # do not consider reversed edges
            consider_reversed_edges = False
    
    pmag's avatar
    pmag committed
            # *********************************************************************
            # *********************************************************************
    
    pmag's avatar
    pmag committed
            # no reversed edges, no self loops, no excluded nodes
            ignore_self_loops = False
            excluded_nodes = []
    
    pmag's avatar
    pmag committed
            straight_paths = gis_iden.find_simplifiable_paths(
    
    Pedro L. Magalhães's avatar
    Pedro L. Magalhães committed
                network,
    
    pmag's avatar
    pmag committed
                excluded_nodes,
                consider_reversed_edges=consider_reversed_edges,
    
    Pedro L. Magalhães's avatar
    Pedro L. Magalhães committed
                ignore_self_loops=ignore_self_loops,
            )
    
    pmag's avatar
    pmag committed
            true_straight_paths = [[0, 1, 2]]
            assert len(straight_paths) == len(true_straight_paths)
            for straight_path in straight_paths:
                assert straight_path in true_straight_paths
    
                self.straight_path_validator(
    
    Pedro L. Magalhães's avatar
    Pedro L. Magalhães committed
                    network,
                    straight_path,
    
    pmag's avatar
    pmag committed
                    excluded_nodes,
    
                    consider_reversed_edges=consider_reversed_edges,
    
    Pedro L. Magalhães's avatar
    Pedro L. Magalhães committed
                    ignore_self_loops=ignore_self_loops,
                )
    
    
    pmag's avatar
    pmag committed
            # *********************************************************************
            # *********************************************************************
    
    pmag's avatar
    pmag committed
            # no reversed edges, allow self loops, no excluded nodes
            ignore_self_loops = True
            excluded_nodes = []
    
    pmag's avatar
    pmag committed
            straight_paths = gis_iden.find_simplifiable_paths(
    
    Pedro L. Magalhães's avatar
    Pedro L. Magalhães committed
                network,
    
    pmag's avatar
    pmag committed
                excluded_nodes,
                consider_reversed_edges=consider_reversed_edges,
    
    Pedro L. Magalhães's avatar
    Pedro L. Magalhães committed
                ignore_self_loops=ignore_self_loops,
            )
    
    pmag's avatar
    pmag committed
            true_straight_paths = [[0, 1, 2]]
            assert len(straight_paths) == len(true_straight_paths)
            for straight_path in straight_paths:
                assert straight_path in true_straight_paths
    
                self.straight_path_validator(
    
    Pedro L. Magalhães's avatar
    Pedro L. Magalhães committed
                    network,
                    straight_path,
                    excluded_nodes,
    
                    consider_reversed_edges=consider_reversed_edges,
    
    Pedro L. Magalhães's avatar
    Pedro L. Magalhães committed
                    ignore_self_loops=ignore_self_loops,
                )
    
    
    pmag's avatar
    pmag committed
            # *********************************************************************
            # *********************************************************************
    
    pmag's avatar
    pmag committed
            # do not allow reversed edges, no self loops, excluded the middle node
            ignore_self_loops = False
            excluded_nodes = [1]
    
    pmag's avatar
    pmag committed
            straight_paths = gis_iden.find_simplifiable_paths(
    
    Pedro L. Magalhães's avatar
    Pedro L. Magalhães committed
                network,
    
    pmag's avatar
    pmag committed
                excluded_nodes,
                consider_reversed_edges=consider_reversed_edges,
    
    Pedro L. Magalhães's avatar
    Pedro L. Magalhães committed
                ignore_self_loops=ignore_self_loops,
            )
    
    pmag's avatar
    pmag committed
            true_straight_paths = []
            assert len(straight_paths) == len(true_straight_paths)
    
    pmag's avatar
    pmag committed
            # *********************************************************************
            # *********************************************************************
    
    pmag's avatar
    pmag committed
            # do not allow reversed edges, no self loops, excluded the start node
            ignore_self_loops = False
            excluded_nodes = [0]
    
    pmag's avatar
    pmag committed
            straight_paths = gis_iden.find_simplifiable_paths(
    
    Pedro L. Magalhães's avatar
    Pedro L. Magalhães committed
                network,
    
    pmag's avatar
    pmag committed
                excluded_nodes,
                consider_reversed_edges=consider_reversed_edges,
    
    Pedro L. Magalhães's avatar
    Pedro L. Magalhães committed
                ignore_self_loops=ignore_self_loops,
            )
    
    pmag's avatar
    pmag committed
            true_straight_paths = [[0, 1, 2]]
            assert len(straight_paths) == len(true_straight_paths)
            for straight_path in straight_paths:
                assert straight_path in true_straight_paths
    
                self.straight_path_validator(
    
    Pedro L. Magalhães's avatar
    Pedro L. Magalhães committed
                    network,
                    straight_path,
    
    pmag's avatar
    pmag committed
                    excluded_nodes,
    
                    consider_reversed_edges=consider_reversed_edges,
    
    Pedro L. Magalhães's avatar
    Pedro L. Magalhães committed
                    ignore_self_loops=ignore_self_loops,
                )
    
    
    pmag's avatar
    pmag committed
            # *********************************************************************
            # *********************************************************************
    
    pmag's avatar
    pmag committed
            # do not allow reversed edges, no self loops, excluded the end node
            ignore_self_loops = False
            excluded_nodes = [2]
    
    pmag's avatar
    pmag committed
            straight_paths = gis_iden.find_simplifiable_paths(
    
    Pedro L. Magalhães's avatar
    Pedro L. Magalhães committed
                network,
    
    pmag's avatar
    pmag committed
                excluded_nodes,
                consider_reversed_edges=consider_reversed_edges,
    
    Pedro L. Magalhães's avatar
    Pedro L. Magalhães committed
                ignore_self_loops=ignore_self_loops,
            )
    
    pmag's avatar
    pmag committed
            true_straight_paths = [[0, 1, 2]]
            assert len(straight_paths) == len(true_straight_paths)
            for straight_path in straight_paths:
                assert straight_path in true_straight_paths
    
                self.straight_path_validator(
    
    Pedro L. Magalhães's avatar
    Pedro L. Magalhães committed
                    network,
                    straight_path,
    
    pmag's avatar
    pmag committed
                    excluded_nodes,
    
                    consider_reversed_edges=consider_reversed_edges,
    
    Pedro L. Magalhães's avatar
    Pedro L. Magalhães committed
                    ignore_self_loops=ignore_self_loops,
                )
    
    
    pmag's avatar
    pmag committed
            # *********************************************************************
            # *********************************************************************
    
    pmag's avatar
    pmag committed
            # consider reversed edges
            consider_reversed_edges = True
    
    pmag's avatar
    pmag committed
            # *********************************************************************
            # *********************************************************************
    
    pmag's avatar
    pmag committed
            # allow reversed edges, allow self loops, no excluded nodes
            ignore_self_loops = True
            excluded_nodes = []
    
    pmag's avatar
    pmag committed
            straight_paths = gis_iden.find_simplifiable_paths(
    
    Pedro L. Magalhães's avatar
    Pedro L. Magalhães committed
                network,
    
    pmag's avatar
    pmag committed
                excluded_nodes,
                consider_reversed_edges=consider_reversed_edges,
    
    Pedro L. Magalhães's avatar
    Pedro L. Magalhães committed
                ignore_self_loops=ignore_self_loops,
            )
    
    pmag's avatar
    pmag committed
            true_straight_paths = [[0, 1, 2], [2, 1, 0]]
    
    Pedro L. Magalhães's avatar
    Pedro L. Magalhães committed
            assert len(straight_paths) == len(true_straight_paths) - 1
    
    pmag's avatar
    pmag committed
            for straight_path in straight_paths:
                assert straight_path in true_straight_paths
    
                self.straight_path_validator(
    
    Pedro L. Magalhães's avatar
    Pedro L. Magalhães committed
                    network,
                    straight_path,
    
    pmag's avatar
    pmag committed
                    excluded_nodes,
    
                    consider_reversed_edges=consider_reversed_edges,
    
    Pedro L. Magalhães's avatar
    Pedro L. Magalhães committed
                    ignore_self_loops=ignore_self_loops,
                )
    
    
    pmag's avatar
    pmag committed
            # *********************************************************************
            # *********************************************************************
    
    pmag's avatar
    pmag committed
            # allow reversed edges, no self loops, no excluded nodes
            ignore_self_loops = False
            excluded_nodes = []
    
    pmag's avatar
    pmag committed
            straight_paths = gis_iden.find_simplifiable_paths(
    
    Pedro L. Magalhães's avatar
    Pedro L. Magalhães committed
                network,
    
    pmag's avatar
    pmag committed
                excluded_nodes,
                consider_reversed_edges=consider_reversed_edges,
    
    Pedro L. Magalhães's avatar
    Pedro L. Magalhães committed
                ignore_self_loops=ignore_self_loops,
            )
    
    pmag's avatar
    pmag committed
            true_straight_paths = [[0, 1, 2], [2, 1, 0]]
    
    Pedro L. Magalhães's avatar
    Pedro L. Magalhães committed
            assert len(straight_paths) == len(true_straight_paths) - 1
    
    pmag's avatar
    pmag committed
            for straight_path in straight_paths:
                assert straight_path in true_straight_paths
    
                self.straight_path_validator(
    
    Pedro L. Magalhães's avatar
    Pedro L. Magalhães committed
                    network,
                    straight_path,
    
    pmag's avatar
    pmag committed
                    excluded_nodes,
    
                    consider_reversed_edges=consider_reversed_edges,
    
    Pedro L. Magalhães's avatar
    Pedro L. Magalhães committed
                    ignore_self_loops=ignore_self_loops,
                )
    
    
    pmag's avatar
    pmag committed
            # *********************************************************************
            # *********************************************************************
    
    pmag's avatar
    pmag committed
            # allow reversed edges, no self loops, excluded the middle node
            ignore_self_loops = False
            excluded_nodes = [1]
    
    pmag's avatar
    pmag committed
            straight_paths = gis_iden.find_simplifiable_paths(
    
    Pedro L. Magalhães's avatar
    Pedro L. Magalhães committed
                network,
    
    pmag's avatar
    pmag committed
                excluded_nodes,
                consider_reversed_edges=consider_reversed_edges,
    
    Pedro L. Magalhães's avatar
    Pedro L. Magalhães committed
                ignore_self_loops=ignore_self_loops,
            )
    
    pmag's avatar
    pmag committed
            true_straight_paths = []
            assert len(straight_paths) == len(true_straight_paths)
    
    pmag's avatar
    pmag committed
            # *********************************************************************
            # *********************************************************************
    
    pmag's avatar
    pmag committed
            # allow reversed edges, no self loops, excluded the start node
            ignore_self_loops = False
            excluded_nodes = [0]
    
    pmag's avatar
    pmag committed
            straight_paths = gis_iden.find_simplifiable_paths(
    
    Pedro L. Magalhães's avatar
    Pedro L. Magalhães committed
                network,
    
    pmag's avatar
    pmag committed
                excluded_nodes,
                consider_reversed_edges=consider_reversed_edges,
    
    Pedro L. Magalhães's avatar
    Pedro L. Magalhães committed
                ignore_self_loops=ignore_self_loops,
            )
    
    pmag's avatar
    pmag committed
            true_straight_paths = [[0, 1, 2], [2, 1, 0]]
    
    Pedro L. Magalhães's avatar
    Pedro L. Magalhães committed
            assert len(straight_paths) == len(true_straight_paths) - 1
    
    pmag's avatar
    pmag committed
            for straight_path in straight_paths:
                assert straight_path in true_straight_paths
    
                self.straight_path_validator(
    
    Pedro L. Magalhães's avatar
    Pedro L. Magalhães committed
                    network,
                    straight_path,
    
    pmag's avatar
    pmag committed
                    excluded_nodes,
    
                    consider_reversed_edges=consider_reversed_edges,
    
    Pedro L. Magalhães's avatar
    Pedro L. Magalhães committed
                    ignore_self_loops=ignore_self_loops,
                )
    
    
    pmag's avatar
    pmag committed
            # *********************************************************************
            # *********************************************************************
    
    pmag's avatar
    pmag committed
            # allow reversed edges, no self loops, excluded the end node
            ignore_self_loops = False
            excluded_nodes = [2]
    
    pmag's avatar
    pmag committed
            straight_paths = gis_iden.find_simplifiable_paths(
    
    Pedro L. Magalhães's avatar
    Pedro L. Magalhães committed
                network,
    
    pmag's avatar
    pmag committed
                excluded_nodes,
                consider_reversed_edges=consider_reversed_edges,
    
    Pedro L. Magalhães's avatar
    Pedro L. Magalhães committed
                ignore_self_loops=ignore_self_loops,
            )
    
    pmag's avatar
    pmag committed
            true_straight_paths = [[0, 1, 2], [2, 1, 0]]
    
    Pedro L. Magalhães's avatar
    Pedro L. Magalhães committed
            assert len(straight_paths) == len(true_straight_paths) - 1
    
    pmag's avatar
    pmag committed
            for straight_path in straight_paths:
                assert straight_path in true_straight_paths
    
                self.straight_path_validator(
    
    Pedro L. Magalhães's avatar
    Pedro L. Magalhães committed
                    network,
                    straight_path,
    
    pmag's avatar
    pmag committed
                    excluded_nodes,
    
                    consider_reversed_edges=consider_reversed_edges,
    
    Pedro L. Magalhães's avatar
    Pedro L. Magalhães committed
                    ignore_self_loops=ignore_self_loops,
                )
    
    
    pmag's avatar
    pmag committed
            # *********************************************************************
            # *********************************************************************
    
    pmag's avatar
    pmag committed
        # *************************************************************************
        # *************************************************************************
    
    pmag's avatar
    pmag committed
        def test_find_simple_straight_path_with_antiparallel_edge(self):
            # *********************************************************************
            # *********************************************************************
    
    pmag's avatar
    pmag committed
            # network with a two edge path
            network = nx.MultiDiGraph()
    
    Pedro L. Magalhães's avatar
    Pedro L. Magalhães committed
            network.add_edges_from([(0, 1, 0), (1, 2, 0), (2, 1, 0)])
    
    
    pmag's avatar
    pmag committed
            # *********************************************************************
            # *********************************************************************
    
    pmag's avatar
    pmag committed
            # do not consider reversed edges
            consider_reversed_edges = False
    
    pmag's avatar
    pmag committed
            # *********************************************************************
            # *********************************************************************
    
    pmag's avatar
    pmag committed
            # no reversed edges, no self loops, no excluded nodes
            ignore_self_loops = False
            excluded_nodes = []
    
    pmag's avatar
    pmag committed
            straight_paths = gis_iden.find_simplifiable_paths(
    
    Pedro L. Magalhães's avatar
    Pedro L. Magalhães committed
                network,
    
    pmag's avatar
    pmag committed
                excluded_nodes,
                consider_reversed_edges=consider_reversed_edges,
    
    Pedro L. Magalhães's avatar
    Pedro L. Magalhães committed
                ignore_self_loops=ignore_self_loops,
            )
    
    pmag's avatar
    pmag committed
            true_straight_paths = [[0, 1, 2]]
            assert len(straight_paths) == len(true_straight_paths)
            for straight_path in straight_paths:
                assert straight_path in true_straight_paths
    
                self.straight_path_validator(
    
    Pedro L. Magalhães's avatar
    Pedro L. Magalhães committed
                    network,
                    straight_path,
    
    pmag's avatar
    pmag committed
                    excluded_nodes,
    
                    consider_reversed_edges=consider_reversed_edges,
    
    Pedro L. Magalhães's avatar
    Pedro L. Magalhães committed
                    ignore_self_loops=ignore_self_loops,
                )
    
    
    pmag's avatar
    pmag committed
            # *********************************************************************
            # *********************************************************************
    
    pmag's avatar
    pmag committed
            # no reversed edges, allow self loops, no excluded nodes
            ignore_self_loops = True