Example #1
0
 def test_airfoil(self):
     graphs.Airfoil()
Example #2
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
Example #3
0
 def test_Airfoil():
     G = graphs.Airfoil()
Example #4
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. 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
Example #5
0
 def test_Airfoil():
     G = graphs.Airfoil()
     needed_attributes_testing(G)