Exemplo n.º 1
0
 def setup_class(cls):
     cls.NXGraph = nx.DiGraph
     edgelist = os.path.expandvars("${GS_TEST_DIR}/dynamic/p2p-31_dynamic.edgelist")
     cls.g = nx.read_edgelist(
         edgelist, nodetype=int, data=True, create_using=cls.NXGraph
     )
     cls.g.add_node(0, vdata_str="kdjfao")
     cls.g.add_node(1, vdata_int=123)
Exemplo n.º 2
0
    def setup_class(cls):
        cls.grid_edges = [
            (1, 2),
            (1, 5),
            (2, 3),
            (2, 6),
            (3, 4),
            (3, 7),
            (4, 8),
            (5, 6),
            (5, 9),
            (6, 7),
            (6, 10),
            (7, 8),
            (7, 11),
            (8, 12),
            (9, 10),
            (9, 13),
            (10, 11),
            (10, 14),
            (11, 12),
            (11, 15),
            (12, 16),
            (13, 14),
            (14, 15),
            (15, 16),
        ]
        cls.grid = nx.Graph()
        cls.grid.add_edges_from(cls.grid_edges, weight=1)
        cls.grid_ans = {
            1: 0,
            5: 1,
            2: 1,
            9: 2,
            6: 2,
            3: 2,
            13: 3,
            10: 3,
            7: 3,
            4: 3,
            14: 4,
            11: 4,
            8: 4,
            15: 5,
            12: 5,
            16: 6,
        }
        cls.grid_path_ans = {
            3: 7,
            4: 8,
            8: 12,
            12: 16,
            1: 5,
            5: 9,
            9: 13,
            2: 3,
            6: 10,
            10: 14,
            7: 11,
            11: 15,
        }

        data_dir = os.path.expandvars("${GS_TEST_DIR}")
        p2p_file = os.path.expandvars(
            "${GS_TEST_DIR}/dynamic/p2p-31_dynamic.edgelist")
        cls.p2p = nx.read_edgelist(p2p_file,
                                   nodetype=int,
                                   data=True,
                                   create_using=nx.DiGraph)
        cls.p2p_undirected = nx.read_edgelist(p2p_file,
                                              nodetype=int,
                                              data=True,
                                              create_using=nx.Graph)
        cls.p2p_length_ans = dict(
            pd.read_csv("{}/p2p-31-sssp".format(data_dir),
                        sep=" ",
                        header=None,
                        prefix="").values)
        cls.p2p_dc_ans = dict(
            pd.read_csv(
                "{}/p2p-31-degree_centrality".format(data_dir),
                sep="\t",
                header=None,
                prefix="",
            ).values)
        cls.p2p_ev_ans = dict(
            pd.read_csv(
                "{}/p2p-31-eigenvector".format(data_dir),
                sep="\t",
                header=None,
                prefix="",
            ).values)
        cls.p2p_kz_ans = dict(
            pd.read_csv("{}/p2p-31-katz".format(data_dir),
                        sep="\t",
                        header=None,
                        prefix="").values)
        cls.p2p_hits_ans = pd.read_csv(
            "{}/p2p-31-hits-directed".format(data_dir),
            sep="\t",
            header=None,
            prefix="")
        cls.p2p_clus_ans = dict(
            pd.read_csv("{}/p2p-31-clustering".format(data_dir),
                        sep=" ",
                        header=None,
                        prefix="").values)
        cls.p2p_triangles_ans = dict(
            pd.read_csv("{}/p2p-31-triangles".format(data_dir),
                        sep=" ",
                        header=None,
                        prefix="").values)
        cls.p2p_kcore_ans = sorted(
            pd.read_csv("{}/p2p-31-kcore".format(data_dir),
                        sep=" ",
                        header=None,
                        prefix="").values)