コード例 #1
0
ファイル: test_graphs.py プロジェクト: andromeda0505/pygsp
 def test_graphtool_export_import(self):
     # Export to graph tool and reimport to PyGSP directly
     # The exported graph is a simple one without an associated Signal
     g = graphs.Bunny()
     g_gt = g.to_graphtool()
     g2 = graphs.Graph.from_graphtool(g_gt)
     np.testing.assert_array_equal(g.W.todense(), g2.W.todense())
コード例 #2
0
def dataSource():
    '''
    source graph
    '''
    G = graphs.Bunny()
    # G.plot()
    # plt.show()
    return G
コード例 #3
0
ファイル: test_graphs.py プロジェクト: andromeda0505/pygsp
    def test_networkx_export_import(self):
        # Export to networkx and reimport to PyGSP

        # Exporting the Bunny graph
        g = graphs.Bunny()
        g_nx = g.to_networkx()
        g2 = graphs.Graph.from_networkx(g_nx)
        np.testing.assert_array_equal(g.W.todense(), g2.W.todense())
コード例 #4
0
ファイル: test_graphs.py プロジェクト: andromeda0505/pygsp
 def test_bunny(self):
     graphs.Bunny()
コード例 #5
0
def real(N, graph_name, connected=True):
    r""" 
    A convenience method for loading toy graphs that have been collected from the internet.
 
	Parameters:
	----------
	N : int 
	    The number of nodes.

	graph_name : a string 
        Use to select which graph is returned. Choices include 
            * airfoil
                Graph from airflow simulation
                http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.50.9217&rep=rep1&type=pdf
                http://networkrepository.com/airfoil1.php
            * yeast
                Network of protein-to-protein interactions in budding yeast.
                http://networkrepository.com/bio-yeast.php
            * minnesota
                Minnesota road network.
                I am using the version provided by the PyGSP software package (initially taken from the MatlabBGL library.)
            * bunny
                The Stanford bunny is a computer graphics 3D test model developed by Greg Turk and Marc Levoy in 1994 at Stanford University
                I am using the version provided by the PyGSP software package.
	connected : Boolean
        Set to True if only the giant component is to be returned.    
"""

    directory = os.path.dirname(graph_utils.__file__) + '/data/'

    tries = 0
    while True:
        tries = tries + 1

        if graph_name == 'airfoil':
            G = graphs.Airfoil()
            G = graphs.Graph(W=G.W[0:N, 0:N], coords=G.coords[0:N, :])

        elif graph_name == 'yeast':
            file = directory + 'bio-yeast.npy'
            W = np.load(file)
            G = graphs.Graph(W=W[0:N, 0:N])

        elif graph_name == 'minnesota':
            G = graphs.Minnesota()
            W = G.W.astype(np.float)
            G = graphs.Graph(W=W[0:N, 0:N], coords=G.coords[0:N, :])

        elif graph_name == 'bunny':
            G = graphs.Bunny()
            W = G.W.astype(np.float)
            G = graphs.Graph(W=W[0:N, 0:N], coords=G.coords[0:N, :])

        if connected == False or G.is_connected(): break
        if tries > 1:
            print(
                'WARNING: disconnected graph.. trying to use the giant component'
            )
            G, _ = graph_utils.get_giant_component(G)
            break
    return G
コード例 #6
0
ファイル: graph_lib.py プロジェクト: yoonkim313/graph_memory
def real(N, graph_name, connected=True):
    r"""
    A convenience method for loading toy graphs that have been collected from the internet.

	Parameters:
	----------
	N : int
	    The number of nodes. Set N=-1 to return the entire graph.

	graph_name : a string
        Use to select which graph is returned. Choices include
            * airfoil
                Graph from airflow simulation
                http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.50.9217&rep=rep1&type=pdf
                http://networkrepository.com/airfoil1.php
            * yeast
                Network of protein-to-protein interactions in budding yeast.
                http://networkrepository.com/bio-yeast.php
            * minnesota
                Minnesota road network.
                I am using the version provided by the PyGSP software package (initially taken from the MatlabBGL library.)
            * bunny
                The Stanford bunny is a computer graphics 3D test model developed by Greg Turk and Marc Levoy in 1994 at Stanford University
                I am using the version provided by the PyGSP software package.
	connected : Boolean
        Set to True if only the giant component is to be returned.
    """

    directory = os.path.join(
        os.path.dirname(os.path.dirname(graph_utils.__file__)), "data"
    )

    tries = 0
    while True:
        tries = tries + 1

        if graph_name == "airfoil":
            G = graphs.Airfoil()
            G = graphs.Graph(W=G.W[0:N, 0:N], coords=G.coords[0:N, :])

        elif graph_name == "yeast":
            W = download_yeast()
            G = graphs.Graph(W=W[0:N, 0:N])

        elif graph_name == "minnesota":
            G = graphs.Minnesota()
            W = G.W.astype(np.float)
            G = graphs.Graph(W=W[0:N, 0:N], coords=G.coords[0:N, :])

        elif graph_name == "bunny":
            G = graphs.Bunny()
            W = G.W.astype(np.float)
            G = graphs.Graph(W=W[0:N, 0:N], coords=G.coords[0:N, :])

        if connected == False or G.is_connected():
            break
        if tries > 1:
            print("WARNING: Disconnected graph. Using the giant component.")
            G, _ = graph_utils.get_giant_component(G)
            break
            
    if not hasattr(G, 'coords'): 
        try:
            import networkx as nx
            graph = nx.from_scipy_sparse_matrix(G.W)
            pos = nx.nx_agraph.graphviz_layout(graph, prog='neato')  
            G.set_coordinates(np.array(list(pos.values()))) 
        except ImportError:
            G.set_coordinates()
        
    return G
コード例 #7
0
ファイル: test_graphs.py プロジェクト: dsacc/pygsp
 def test_Bunny():
     G = graphs.Bunny()
コード例 #8
0
ファイル: test_plotting.py プロジェクト: dsacc/pygsp
 def test_Bunny():
     G = graphs.Bunny()
     needed_attributes_testing(G)