示例#1
0
def test_relaxed_caveman_graph():
    G = nx.relaxed_caveman_graph(4, 3, 0)
    assert_equal(len(G), 12)
    G = nx.relaxed_caveman_graph(4, 3, 1)
    assert_equal(len(G), 12)
    G = nx.relaxed_caveman_graph(4, 3, 0.5)
    assert_equal(len(G), 12)
示例#2
0
def test_relaxed_caveman_graph():
    G = nx.relaxed_caveman_graph(4, 3, 0)
    assert_equal(len(G), 12)
    G = nx.relaxed_caveman_graph(4, 3, 1)
    assert_equal(len(G), 12)
    G = nx.relaxed_caveman_graph(4, 3, 0.5)
    assert_equal(len(G), 12)
示例#3
0
def test_relaxed_caveman_graph():
    G = nx.relaxed_caveman_graph(4, 3, 0)
    assert len(G) == 12
    G = nx.relaxed_caveman_graph(4, 3, 1)
    assert len(G) == 12
    G = nx.relaxed_caveman_graph(4, 3, 0.5)
    assert len(G) == 12
    G = nx.relaxed_caveman_graph(4, 3, 0.5, seed=42)
    assert len(G) == 12
示例#4
0
def GeneraGrafoRandom(kind, seed=None, dim=60, prob=0.09):
    if kind not in graph_kind:
        print "Unknown graph type"
        exit()
    if kind == "caveman":
        if dim <= 15:
            g = nx.relaxed_caveman_graph(dim, 10, p=prob, seed=seed)
        else:
            g = nx.relaxed_caveman_graph(10, dim, p=prob, seed=seed)
    if kind == "waxman":
        g = nx.waxman_graph(dim, alpha=1.05, beta=prob)
    if kind == "erdos":
        g = nx.gnp_random_graph(dim, p=prob, seed=seed)
    if kind == "barabasi":
        g = nx.barabasi_albert_graph(dim, m=prob, seed=seed)

    rapportoespansione = [False] * 75 + [True] * 25
    maxinterfacce = 8

    g.remove_nodes_from(nx.isolates(g))

    nx.set_node_attributes(g, 'n_interf', 0)
    nx.set_edge_attributes(g, 'ID', '')

    for n, d in g.nodes_iter(data=True):
        if kind == "waxman":
            del d['pos']

        MenoInterf = random.choice(rapportoespansione)
        if (MenoInterf == False):
            d['n_interf'] = 1
        else:
            d['n_interf'] = random.randint(1, min(g.degree(n), maxinterfacce))

    i = 0
    for u, v, d in g.edges(data=True):
        d['ID'] = 'e' + str(i)
        d['weight'] = float(np.random.uniform(1.0, 1.1))
        i += 1

    if nx.is_connected(g) == False:
        g = GeneraGrafoRandom(kind=kind, seed=seed, dim=dim, prob=prob)

    mapping = {}
    for x in g.nodes():
        mapping[x] = str(x)

    g = nx.relabel_nodes(g, mapping, copy=False)

    return g
示例#5
0
文件: main.py 项目: Hayato0812/Zemi
    def __init__(self, ):
        self.agentGroupList = []
        self.agentList = []
        self.baseMetrics = []

        #エージェントを全員作る
        for i in range(Setting.AGENT_NUM_IN_ONE_GROUP *
                       Setting.AGENT_GROUP_NUM):
            self.agentList.append(Agent(i))

        #ベースとなる評価指標を作る
        for i in range(Setting.GYOMU_NUM - Setting.GROUP_DIFFERENCE):
            self.baseMetrics.append(Metrics())

        #評価指標が異なるエージェントグループを作る
        for i in range(Setting.AGENT_GROUP_NUM):
            self.agentGroupList.append(AgentGroup(i, self.baseMetrics))

        #エージェントグループにエージェントを入れる
        for agentGroup in self.agentGroupList:
            for i in range(Setting.AGENT_NUM_IN_ONE_GROUP):
                agentGroup.addAgent(
                    self.agentList[i + agentGroup.id *
                                   Setting.AGENT_NUM_IN_ONE_GROUP])

        #ネットワークを作り、エージェントを繋げる
        self.G = nx.relaxed_caveman_graph(Setting.AGENT_GROUP_NUM,
                                          Setting.AGENT_NUM_IN_ONE_GROUP,
                                          Setting.BETA)
        relations = nx.to_dict_of_lists(self.G)
        for i in range(len(relations)):
            self.agentList[i].connect(relations[i], self.agentList)

        self.Alldata = []
示例#6
0
def initialize_state():
    '''
            G
            S
            A
            I
            R
            D
            T: timesteps
            a_i(people_obj): returns a probability that an a node transitions to the I state
            a_r(people_obj): returns a probability that a node transitions to the R state
            die(people_obj): returns a probability that this person will die
            policy : policy function to be performed every epoch/timestep
    '''
    G = nx.relaxed_caveman_graph(10, 5, .2)

    attributes = {}
    for node in G.nodes():
        attributes[node] = {
            'age': int(random.normalvariate(38, 13)),
            'state': "S",
            'underlying_condition': False,
            'time_infection': -1,
            'time_removal': -1,
            'contacts': [],
            'dead': False
        }
    nx.set_node_attributes(G, attributes)

    for node in random.sample(G.nodes(), 3):
        G.nodes[node]["state"] = "I"

    for node in G.nodes():
        for neighbor in G[node]:
            G.add_edge(node, neighbor, weight=random.random())

    T = 25

    def a_i(person):
        return 0.2

    def a_r(person):
        return 1.0 / 14.0

    def die(person):
        return 0.03

    def policy(G):
        return

    lines = simulate_corona(G, 47, 0, 3, 0, 0, T, a_i, a_r, die, policy)
    time_steps = [i for i in range(T + 1)]

    plt.plot(time_steps, lines[0], label="susceptible")
    plt.plot(time_steps, lines[1], label="asymptomatic")
    plt.plot(time_steps, lines[2], label="infected")
    plt.plot(time_steps, lines[3], label="removed")
    plt.plot(time_steps, lines[4], label="dead")
    plt.legend()
    plt.show()
def create_graphs():
    path = 'data/'
    for x in range(0, 10):
        random = nx.erdos_renyi_graph(14235, .007)
        ba = nx.barabasi_albert_graph(14235, 2)
        rc = nx.relaxed_caveman_graph(356, 40, .10)
        random_save_path = '{0}{1}{2}.gml'.format(path, 'er', x)
        nx.write_gml(random, random_save_path)
        ba_save_path = '{0}{1}{2}.gml'.format(path, 'ba', x)
        nx.write_gml(ba, ba_save_path)
        rc_save_path = '{0}{1}{2}.gml'.format(path, 'rc', x)
        nx.write_gml(rc, rc_save_path)
示例#8
0
 def get_edge_list():
     cn = relaxed_caveman_graph(GC.cave_num_cliques, GC.cave_clique_size, GC.cave_prob, seed=GC.random_number_seed)
     if GC.random_number_seed is not None:
         GC.random_number_seed += 1
     out = GC.nx2favites(cn, 'u')
     f = gopen(expanduser("%s/contact_network.txt.gz" % GC.out_dir),'wb',9)
     f.write('\n'.join(out).encode()); f.write(b'\n')
     f.close()
     GC.cn_communities = [{c*GC.cave_clique_size+i for i in range(GC.cave_clique_size)} for c in range(GC.cave_num_cliques)]
     f = gopen(expanduser("%s/contact_network_partitions.txt.gz" % GC.out_dir),'wb',9)
     f.write(str(GC.cn_communities).encode()); f.write(b'\n')
     f.close()
     GC.cn_communities = [{str(i) for i in c} for c in GC.cn_communities]
     return out
示例#9
0
def ut_getWeightClusterGraph(k, n, uc, uo):
    G = nx.relaxed_caveman_graph(k, n, 0.15)

    # add weights to intra-cluster edges
    edges = G.edges()
    eWeights = {}
    for e in edges:
        eWeights[e] = float(np.random.normal(uc, 1.0, 1))
    nx.set_edge_attributes(G, 'weight', eWeights)

    # add edges between clusters (weaker than within clusters)
    nedges = nx.non_edges(G)
    eWeights = {}
    for e in nedges:
        G.add_edge(e[0], e[1], weight=float(np.random.normal(uo, 1.0, 1)))

    return G
示例#10
0
def initGeneralPopulation():
    # General Population variables
    gpEdgeProb = .6  # Probability for edge creation
    gpEdgeWeight = 1

    # create graph
    gp = nx.relaxed_caveman_graph(g, gs, gpEdgeProb, seed=seed)

    # label all depending on probability of passive or not
    for u, d in list(gp.nodes(data=True)):
        d['type'] = PASSIVE if (
            np.random.uniform(0, 1, 1) < passiveProb) else NEUTRAL

    # reweight the edges
    for (u, v) in gp.edges:
        gp[u][v]['weight'] = gpEdgeWeight

    # return the new graph
    return gp
示例#11
0
def initExtremePopulation():
    # Extremist Population variables
    epEdgeProb = .9  # Probability for edge creation
    epEdgeWeight = 1
    epGroups = int(initPE * g) + 1

    #create the new graph
    ep = nx.relaxed_caveman_graph(epGroups, gs, epEdgeProb, seed=seed)

    # reweight the edges
    for (u, v) in ep.edges:
        ep[u][v]['weight'] = epEdgeWeight

    # label all as extremists
    for u, d in list(ep.nodes(data=True)):
        d['type'] = EXTREMIST

    #return the new graph
    return ep
示例#12
0
def community_graphs():
    print("Community graphs for social networks")
    print("Caveman graph")
    G = nx.caveman_graph(2, 13)
    draw_graph(G)
    print(" Connected Caveman graph")
    G = nx.connected_caveman_graph(2, 3)
    draw_graph(G)
    print("Relaxed caveman")
    G = nx.relaxed_caveman_graph(2, 5, 0.2)
    draw_graph(G)
    print("Random partition graph")
    G = nx.random_partition_graph([10, 10, 10], .25, .01)
    draw_graph(G)
    print(len(G))
    partition = G.graph['partition']
    print(len(partition))
    print("Planted partition graph")
    G = nx.planted_partition_graph(4, 3, 0.5, 0.1, seed=42)
    draw_graph(G)
    print("Gaussian random partition graph")
    G = nx.gaussian_random_partition_graph(40, 10, 10, .25, .1)
    print(len(G))
    draw_graph(G)
示例#13
0
    def _create_random_graph(self, graph_type=None, number_of_people=0):
        if graph_type not in ['Tree', 'Ring of Cliques', 'Random']:
            print("Please enter a valid random graph type.")
            raise ValueError

        if number_of_people == 0:
            print(
                "Please enter a number greater than zero for the number of people"
            )
            raise ValueError

        if graph_type == 'Tree' and number_of_people > 0:
            self.G = nx.random_tree(number_of_people)
            return True

        if graph_type == 'Ring of Cliques':
            num_cliques = random.randint(5, 10)
            clique_size = random.randint(3, 6)
            prob = random.random()
            self.G = nx.relaxed_caveman_graph(num_cliques, clique_size, prob)
            return True

        if graph_type == 'Random':
            return False
示例#14
0
import networkx as nx
import matplotlib.pyplot as plt

savePlots = 1
showPlots = 1

# G = nx.random_geometric_graph(30, 0.3)
# G = nx.connected_caveman_graph(4,9)
G = nx.relaxed_caveman_graph(4, 9, 0.2, seed=42)
# G = nx.karate_club_graph()

nx.draw(G, node_size=100)

if savePlots:
    filename = 'graph.png'
    plt.savefig(filename, bbox_inches="tight")

######### Show the plots #########

if showPlots:
    plt.show()
import networkx as nx
import argparse
import matplotlib.pyplot as plt

def write_to_csv(G,path):
    df=nx.to_pandas_edgelist(G)
    df.to_csv(path)


#n = 6
parser= argparse.ArgumentParser(8)
parser.add_argument('--n', type=int)
parser.add_argument('--k', type= int)
args=parser.parse_args()
n=args.n
k=args.k
l=int(n/k)
G = nx.relaxed_caveman_graph(l,k,0)
write_to_csv(G, "C:/Users/Anni/Documents/Uni/Computer Science/Proj/CSVs and text files/FacebookUK/small_world_graph.csv")
#nx.draw(G,with_labels=False,pos=nx.spectral_layout(G),
 #      node_size=10,linewidths=0.1,width=0.01,node_color=range(1000),
  #    cmap=plt.cm.Blues)

#plt.savefig("C:/Users/Anni/Documents/Uni/Computer "
#            "Science/Proj/Network Diagrams/MostRecentNxDrawing.png")
			
print("Done with n="+str(n))
示例#16
0
        nx.draw_networkx(
            G,
            node_color=Color(G),
            node_size=50,
            with_labels=False,
            ax=ax[k - 1]
        )  #We do not fix the position here to get a more presentable graph.
        ax[k - 1].set_title(
            "% infected at the end: {0:.2f}%".format(infected_percentage))
    plt.show()


Simulate(G, plot_all=True, plot_final=True)
Simulate(G, plot_all=True, plot_final=True)

G1 = nx.relaxed_caveman_graph(10, 6, 0.3, seed=17)

Populate(G1)
infection_seed = np.random.randint(len(G1.nodes()))
G1.nodes[infection_seed]['I'] = 'red'

nx.draw_networkx(G1, node_color=Color(G1), with_labels=False, node_size=30)

G2 = nx.windmill_graph(4, 5)

Populate(G2)
infection_seed = np.random.randint(len(G2.nodes()))
G2.nodes[infection_seed]['I'] = 'red'

nx.draw_networkx(G2, node_color=Color(G2), with_labels=False, node_size=30)
                     edge_color=edge_colour,
                     with_labels=with_labels,
                     node_size=node_size)
    plt.draw()
    plt.show()


# randomly partitioned graph
# random_partition_graph(sizes, p_in, p_out, seed=None, directed=False)
node_size = 1
number_clusters = 8
nodes = [node_size for _ in range(number_clusters)]
G = nx.random_partition_graph(nodes, 0.2, 1.00, directed=False)

# G = nx.powerlaw_cluster_graph(200,5,0.0)
G = nx.relaxed_caveman_graph(8, 16, 0.05)

#draw_and_plot(G)

# custom graph (hyperedges)
#G = nx.DiGraph()
#nodes = [x for x in range(16)]
#G.add_nodes_from(nodes)
#edges0 = [(15,0),(15,8)]
#G.add_edges_from(edges0,color='black')
#edges1 = [(0,1),(0,2),(0,3),(0,4),(0,5),(0,6),(0,7)]
#G.add_edges_from(edges1,color='r')
#edges2 = [(8,9),(8,10),(8,11),(8,12),(8,13),(8,14)]
#G.add_edges_from(edges2,color='g')
#edge_colours = [G[u][v]['color'] for u,v in G.edges()]
#draw_and_plot(G,with_labels=True,node_colour='white',edge_colour=edge_colours,node_size=700)
示例#18
0
        print(f'Processing city number {city_i} : {city_name}')

        n_groups = int(city_population / MEAN_CONTACTS)

        try:
            H = nx.connected_watts_strogatz_graph(int(0.7 * city_population), 50, 0.2)
            I = nx.connected_watts_strogatz_graph(int(0.2 * city_population), 70, 0.15)
            J = nx.connected_watts_strogatz_graph(int(0.1 * city_population), 100, 0.05)

            G = nx.compose(H, I)
            city_graph = nx.compose(G, J)

            # city_graph = nx.powerlaw_cluster_graph(city_population, 20, 0.05)

        except nx.exception.NetworkXError:
            city_graph = nx.relaxed_caveman_graph(n_groups, MEAN_CONTACTS, REWIRING)

        edges = city_graph.edges()

        start_vertices = [e[0] for e in edges]
        end_vertices = [e[1] for e in edges]

        current_start_vert = -1
        egde_i = 0

        for vertex_start, vertex_end in zip(start_vertices, end_vertices):
            if vertex_start != current_start_vert:
                current_start_vert = vertex_start

                egde_i = 0
    def scenario(self, size):

        if not os.path.exists('{}/S{}'.format(OUT_DIR, SCENARIO)):
            os.mkdir('{}/S{}'.format(OUT_DIR, SCENARIO))

        if os.path.exists('{}/S{}/C{}'.format(OUT_DIR, SCENARIO, CASE)):
            shutil.rmtree('{}/S{}/C{}'.format(OUT_DIR, SCENARIO, CASE))

        os.mkdir('{}/S{}/C{}'.format(OUT_DIR, SCENARIO, CASE))

        if SCENARIO == 1:
            # random graph, random intro
            net = Network(size, permanent_infection=False)
            net.generate(nx.erdos_renyi_graph(size, 10 / size))
            net.introduce_contagion(chance=1,
                                    contagion=Contagion(c_id=0,
                                                        t_num=3,
                                                        color=(0.8, 0.2, 0.2)))
            net.introduce_contagion(chance=1,
                                    contagion=Contagion(c_id=1,
                                                        t_num=3,
                                                        color=(0.2, 0.2, 0.8)))
            result = net.infect()[1]
            # net.draw(force=True)
            self.plot_composition(result, size)

            return result

        if SCENARIO == 2:
            net = Network(size, permanent_infection=False)
            net.generate(nx.erdos_renyi_graph(size, 20 / size))
            net.introduce_contagion(
                contagion=Contagion(c_id=0, t_num=5, color=(0.8, 0.2, 0.2)))
            net.introduce_contagion(
                contagion=Contagion(c_id=1, t_num=5, color=(0.2, 0.2, 0.8)))
            result = net.infect()[1]
            self.plot_composition(result, size)
            return result

        if SCENARIO == 3:
            net = Network(size, permanent_infection=False)
            net.generate(nx.barabasi_albert_graph(size, 5))
            net.introduce_contagion(
                contagion=Contagion(c_id=0, t_num=5, color=(0.8, 0.2, 0.2)))
            net.introduce_contagion(
                contagion=Contagion(c_id=1, t_num=5, color=(0.2, 0.2, 0.8)))
            result = net.infect()[1]
            self.plot_composition(result, size)
            return result

        if SCENARIO == 4:
            net = Network(size, permanent_infection=False)
            net.generate(nx.karate_club_graph())
            net.introduce_contagion(contagion=Contagion(c_id=0,
                                                        t_num=3,
                                                        color=(0.8, 0.2, 0.2)),
                                    chance=0.3)
            net.introduce_contagion(contagion=Contagion(c_id=1,
                                                        t_num=3,
                                                        color=(0.2, 0.2, 0.8)),
                                    chance=0.3)
            result = net.infect()[1]
            self.plot_composition(result, size)
            return result

        if SCENARIO == 5:
            net = Network(size, permanent_infection=False)
            net.generate(nx.relaxed_caveman_graph(5, 10, 0.4))
            net.introduce_contagion(contagion=Contagion(c_id=0,
                                                        t_num=4,
                                                        color=(0.8, 0.2, 0.2)),
                                    chance=0.5)
            net.introduce_contagion(contagion=Contagion(c_id=1,
                                                        t_num=4,
                                                        color=(0.2, 0.2, 0.8)),
                                    chance=0.5)
            result = net.infect()[1]
            self.plot_composition(result, size)
            return result

        if SCENARIO == 6:
            net = Network(size, permanent_infection=False)
            net.generate(nx.relaxed_caveman_graph(5, 10, 0.2))
            net.introduce_contagion(contagion=Contagion(c_id=0,
                                                        t_num=2,
                                                        color=(0.8, 0.2, 0.2),
                                                        loyalty=0),
                                    chance=0.5)
            net.introduce_contagion(contagion=Contagion(c_id=1,
                                                        t_num=2,
                                                        color=(0.2, 0.2, 0.8),
                                                        loyalty=0),
                                    chance=0.5)
            result = net.infect()[1]
            self.plot_composition(result, size)
            return result

        if SCENARIO == 7:
            net = Network(size, permanent_infection=False)
            net.generate(nx.relaxed_caveman_graph(5, 10, 0.2))
            net.introduce_contagion(contagion=Contagion(c_id=0,
                                                        t_num=2,
                                                        color=(0.8, 0.2, 0.2),
                                                        loyalty=0),
                                    chance=0.5)
            net.introduce_contagion(contagion=Contagion(c_id=1,
                                                        t_num=3,
                                                        color=(0.2, 0.2, 0.8),
                                                        loyalty=MAX_LOYALTY),
                                    chance=0.5)
            result = net.infect()[1]
            self.plot_composition(result, size)
            return result

        return None
示例#20
0
import json
from networkx.readwrite import json_graph
import his
import icc
import bicc
import wx


# create our little application :)
app = Flask(__name__)
graph = {}
area = []
edge = 0

#生成图结构,并存储到json文件中
G = nx.relaxed_caveman_graph(10, 10, 0.1, seed=42)
partition = community.best_partition(G)
for n in G:
    G.node[n]['name'] = n
    G.node[n]['group'] = partition[n]
    graph[n] = []
    for k, v in G.edge[n].items():
        graph[n].append(k)
        edge += 1
    area.append(partition[n])
d = json_graph.node_link_data(G)
json.dump(d, open('static/force/community_Picture.json', 'w'))

# Load default config and override config from an environment variable
app.config.update(dict(
    DATABASE=os.path.join(app.root_path, 'flaskr.db'),
示例#21
0
    ax1.axvline(n_triangles,
                color='r')  # n_triangles as obtained for the full network
    ax2.axvline(transit, color='r')  # transit as obtained for the full network

    ax1.legend(loc=0)
    ax2.legend(loc=0)
    fig.tight_layout()
    fig.savefig('ht_estimator_sampling_{}.pdf'.format(sampling_type))


#  ===================== MAIN CODE BELOW =======================

if __name__ == '__main__':

    # Generate network
    g = nx.relaxed_caveman_graph(200, 10, .1)
    # e)
    # Empirical estimators for sampling nodes
    probabilites = [.1, .3, .5, 1]
    print(' --------- Sampling nodes ---------')
    print('p     | triangles | two-stars | transitivity | ')
    for p in probabilites:
        if p == 1:
            g_new = g
        else:
            g_new = sample_nodes(g, p)

        n_triangles = count_triangles(g_new)
        n_twostars = count_twostars(g_new)
        transit = transitivity(n_triangles, n_twostars)
        print('%2.2f  |  %7d  |  %7d  |  %4.4f      |' %
示例#22
0
from netgan import netgan
from netgan import utils
import networkx as nx
import scipy.sparse as sp
import numpy as np

# try out a simple netgan
if __name__ == "__main__":
    # some parameters
    N = 100
    rw_len = 50

    # create an adjacency matrix
    G = nx.relaxed_caveman_graph(10, 10, 0.1)
    G.remove_edges_from(G.selfloop_edges())
    adj = nx.adjacency_matrix(G)

    # split up edges apparently (would rather just split up graphs)
    val_share = 0.1
    test_share = 0.05
    train_ones, val_ones, val_zeros, test_ones, test_zeros = utils.train_val_test_split_adjacency(
        adj,
        val_share,
        test_share,
        undirected=True,
        connected=True,
        asserts=True)
    train_graph = sp.coo_matrix(
        (np.ones(len(train_ones)), (train_ones[:, 0], train_ones[:,
                                                                 1]))).tocsr()
示例#23
0
def create(args):
    ### load datasets
    graphs = []
    # synthetic graphs
    if args.graph_type == 'ladder':
        graphs = []
        for i in range(100, 201):
            graphs.append(nx.ladder_graph(i))
        args.max_prev_node = 10
    elif args.graph_type == 'ladder_small':
        graphs = []
        for i in range(2, 11):
            graphs.append(nx.ladder_graph(i))
        args.max_prev_node = 10
    elif args.graph_type == 'tree':
        graphs = []
        for i in range(2, 5):
            for j in range(3, 5):
                graphs.append(nx.balanced_tree(i, j))
        args.max_prev_node = 256
    elif args.graph_type == 'caveman':
        # graphs = []
        # for i in range(5,10):
        #     for j in range(5,25):
        #         for k in range(5):
        #             graphs.append(nx.relaxed_caveman_graph(i, j, p=0.1))
        graphs = []
        for i in range(2, 3):
            for j in range(30, 81):
                for k in range(10):
                    graphs.append(caveman_special(i, j, p_edge=0.3))
        args.max_prev_node = 100
    elif args.graph_type == 'caveman_small2':
        # graphs = []
        # for i in range(2,5):
        #     for j in range(2,6):
        #         for k in range(10):
        #             graphs.append(nx.relaxed_caveman_graph(i, j, p=0.1))
        graphs = []
        for j in range(6, 11):
            for k in range(20):
                G = nx.relaxed_caveman_graph(2, int(1.5 * j), p=0.15)
                G.graph['Z'] = np.array([1, 0])
                graphs.append(G)
        args.max_prev_node = 20
    elif args.graph_type == 'caveman_small':
        # graphs = []
        # for i in range(2,5):
        #     for j in range(2,6):
        #         for k in range(10):
        #             graphs.append(nx.relaxed_caveman_graph(i, j, p=0.1))
        graphs = []
        for i in range(2, 3):
            for j in range(6, 11):
                for k in range(20):
                    graphs.append(caveman_special(i, j,
                                                  p_edge=0.8))  # default 0.8
        args.max_prev_node = 20
    elif args.graph_type == 'caveman_small3':
        # graphs = []
        # for i in range(2,5):
        #     for j in range(2,6):
        #         for k in range(10):
        #             graphs.append(nx.relaxed_caveman_graph(i, j, p=0.1))
        graphs = []
        for j in range(6, 11):
            for k in range(20):
                #G = caveman_special(3,j,p_edge=1)
                G = nx.relaxed_caveman_graph(3, j, p=0.15)
                G.graph['Z'] = np.array([0, 1])
                graphs.append(G)
        args.max_prev_node = 20
    elif args.graph_type == 'caveman_small_mixed':
        graphs = []
        for j in range(18, 19):
            for k in range(50):
                G = nx.relaxed_caveman_graph(2, int(j), p=0.15)
                G.graph['Z'] = np.array([1, 0])
                graphs.append(G)
        # for j in range(6, 11):
#             for k in range(20):
#                 #G = caveman_special(3,j,p_edge=1)
#                 G = nx.relaxed_caveman_graph(3,j,p=0.15)
#                 G.graph['Z'] = np.array([1,0])
#                 graphs.append(G)
        for i in range(6, 7):
            for j in range(6, 7):
                for k in range(50):
                    G = nx.grid_2d_graph(i, j)
                    G.graph['Z'] = np.array([0, 1])
                    graphs.append(G)
        args.max_prev_node = 30
    elif args.graph_type == 'caveman_small_single':
        # graphs = []
        # for i in range(2,5):
        #     for j in range(2,6):
        #         for k in range(10):
        #             graphs.append(nx.relaxed_caveman_graph(i, j, p=0.1))
        graphs = []
        for i in range(2, 3):
            for j in range(8, 9):
                for k in range(100):
                    graphs.append(caveman_special(i, j, p_edge=0.5))
        args.max_prev_node = 20
    elif args.graph_type.startswith('community'):
        num_communities = int(args.graph_type[-1])
        print('Creating dataset with ', num_communities, ' communities')
        c_sizes = np.random.choice([12, 13, 14, 15, 16, 17], num_communities)
        #c_sizes = [15] * num_communities
        for k in range(3000):
            graphs.append(n_community(c_sizes, p_inter=0.01))
        args.max_prev_node = 80
    elif args.graph_type == 'grid':
        graphs = []
        for i in range(10, 20):
            for j in range(10, 20):
                graphs.append(nx.grid_2d_graph(i, j))
        args.max_prev_node = 40
    elif args.graph_type == 'grid_small':
        graphs = []
        for i in range(2, 5):
            for j in range(2, 6):
                graphs.append(nx.grid_2d_graph(i, j))
        args.max_prev_node = 15
    elif args.graph_type == 'barabasi':
        graphs = []
        for i in range(100, 200):
            for j in range(4, 5):
                for k in range(5):
                    graphs.append(nx.barabasi_albert_graph(i, j))
        args.max_prev_node = 130
    elif args.graph_type == 'barabasi_small':
        graphs = []
        for i in range(4, 21):
            for j in range(3, 4):
                for k in range(10):
                    graphs.append(nx.barabasi_albert_graph(i, j))
        args.max_prev_node = 20
    elif args.graph_type == 'grid_big':
        graphs = []
        for i in range(36, 46):
            for j in range(36, 46):
                graphs.append(nx.grid_2d_graph(i, j))
        args.max_prev_node = 90

    elif args.graph_type == 'sbm_large':
        N = 100
        graphs = generateSetOfSBM([[N // x] * x for x in [2, 4] * 500])

        args.max_prev_node = 60
        args.max_num_node = 100

    elif 'barabasi_noise' in args.graph_type:
        graphs = []
        for i in range(100, 101):
            for j in range(4, 5):
                for k in range(500):
                    graphs.append(nx.barabasi_albert_graph(i, j))
        graphs = perturb_new(graphs, p=args.noise / 10.0)
        args.max_prev_node = 99

    # real graphs
    elif args.graph_type == 'enzymes':
        graphs = Graph_load_batch(min_num_nodes=10, name='ENZYMES')
        args.max_prev_node = 25
    elif args.graph_type == 'enzymes_small':
        graphs_raw = Graph_load_batch(min_num_nodes=10, name='ENZYMES')
        graphs = []
        for G in graphs_raw:
            if G.number_of_nodes() <= 20:
                graphs.append(G)
        args.max_prev_node = 15
    elif args.graph_type == 'protein':
        graphs = Graph_load_batch(min_num_nodes=20, name='PROTEINS_full')
        args.max_prev_node = 80
    elif args.graph_type == 'DD':
        graphs = Graph_load_batch(min_num_nodes=100,
                                  max_num_nodes=500,
                                  name='DD',
                                  node_attributes=False,
                                  graph_labels=True)
        args.max_prev_node = 230
    elif args.graph_type == 'citeseer':
        _, _, G = Graph_load(dataset='citeseer')
        G = max(nx.connected_component_subgraphs(G), key=len)
        G = nx.convert_node_labels_to_integers(G)
        graphs = []
        for i in range(G.number_of_nodes()):
            G_ego = nx.ego_graph(G, i, radius=3)
            if G_ego.number_of_nodes() >= 50 and (G_ego.number_of_nodes() <=
                                                  400):
                graphs.append(G_ego)
        args.max_prev_node = 250
    elif args.graph_type == 'citeseer_small':
        _, _, G = Graph_load(dataset='citeseer')
        G = max(nx.connected_component_subgraphs(G), key=len)
        G = nx.convert_node_labels_to_integers(G)
        graphs = []
        for i in range(G.number_of_nodes()):
            G_ego = nx.ego_graph(G, i, radius=1)
            if (G_ego.number_of_nodes() >= 4) and (G_ego.number_of_nodes() <=
                                                   20):
                graphs.append(G_ego)
        shuffle(graphs)
        graphs = graphs[0:200]
        args.max_prev_node = 15

    return graphs