Module Expr Str Import alias Import alias Import alias Import alias identifier Assign NameStore Call AttributeLoad Str attr ListLoad Str Str Str Assign NameStore ListLoad Str Str Str Str Str Str Str FunctionDef arguments args NameParam NameParam defaults body Expr Str Assign NameStore Call AttributeLoad NameLoad attr BinOpMult NameLoad NameLoad Assign AttributeStore NameLoad attr BinOpMod Str TupleLoad BinOpMult NameLoad NameLoad NameLoad If CompareGt NameLoad Num body For NameStore Call NameLoad Num BinOpMult NameLoad NameLoad NameLoad body Assign NameStore Call AttributeLoad NameLoad attr Call NameLoad NameLoad BinOpAdd NameLoad NameLoad Num Expr Call AttributeLoad NameLoad attr NameLoad Return NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str Assign NameStore Call AttributeLoad NameLoad attr NameLoad NameLoad Assign AttributeStore NameLoad attr BinOpMod Str TupleLoad NameLoad NameLoad For NameStore Call NameLoad Num BinOpMult NameLoad NameLoad NameLoad body Expr Call AttributeLoad NameLoad attr NameLoad BinOpAdd NameLoad Num Expr Call AttributeLoad NameLoad attr NameLoad BinOpMod BinOpSub NameLoad Num BinOpMult NameLoad NameLoad Return NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam NameParam defaults NameLoad body Expr Str If UnaryOpNot CompareIs NameLoad NameLoad body Expr Call AttributeLoad NameLoad attr NameLoad Assign NameStore Call AttributeLoad NameLoad attr NameLoad NameLoad Assign NameStore Call NameLoad NameLoad Assign AttributeStore NameLoad attr BinOpMod Str TupleLoad NameLoad NameLoad NameLoad For TupleStore NameStore NameStore Call AttributeLoad NameLoad attr body If CompareLt Call AttributeLoad NameLoad attr NameLoad body Assign NameStore Call AttributeLoad NameLoad attr NameLoad If Call AttributeLoad NameLoad attr NameLoad NameLoad body Continue Expr Call AttributeLoad NameLoad attr NameLoad NameLoad Expr Call AttributeLoad NameLoad attr NameLoad NameLoad Return NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam NameParam NameParam defaults NameLoad NameLoad body Expr Str If UnaryOpNot CompareIs NameLoad NameLoad body Expr Call AttributeLoad NameLoad attr NameLoad If UnaryOpNot CompareLtELtE Num NameLoad Num body Raise Call AttributeLoad NameLoad attr Str If UnaryOpNot CompareLtELtE Num NameLoad Num body Raise Call AttributeLoad NameLoad attr Str If NameLoad body Assign NameStore Call AttributeLoad NameLoad attr orelse Assign NameStore Call AttributeLoad NameLoad attr Assign SubscriptStore AttributeLoad NameLoad attr Index Str ListLoad Assign NameStore Call NameLoad NameLoad Expr Call AttributeLoad NameLoad attr Call NameLoad NameLoad Assign NameStore Dict Assign NameStore Num Assign NameStore Num For NameStore NameLoad body Assign NameStore GeneratorExp TupleLoad BinOpAdd NameLoad NameLoad BinOpAdd NameLoad NameLoad comprehension TupleStore NameStore NameStore Call AttributeLoad Call AttributeLoad NameLoad attr NameLoad NameLoad keyword NameLoad attr Expr Call AttributeLoad NameLoad attr NameLoad Expr Call AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr Call NameLoad NameLoad BinOpAdd NameLoad NameLoad BinOpAdd NameLoad NameLoad Expr Call AttributeLoad SubscriptLoad AttributeLoad NameLoad attr Index Str attr Call NameLoad Call NameLoad NameLoad BinOpAdd NameLoad NameLoad AugAssignAdd NameStore Num AugAssignAdd NameStore NameLoad If CompareEq NameLoad Num body Return NameLoad If CompareEq NameLoad Num body For NameStore NameLoad body Assign NameStore Call NameLoad SubscriptLoad NameLoad Index NameLoad Call NameLoad NameLoad Expr Call AttributeLoad NameLoad attr Call NameLoad BinOpMult ListLoad NameLoad Call NameLoad NameLoad NameLoad If NameLoad body Expr Call AttributeLoad NameLoad attr Call NameLoad NameLoad BinOpMult ListLoad NameLoad Call NameLoad NameLoad Return NameLoad Assign NameStore Call AttributeLoad NameLoad attr BinOpSub Num NameLoad Assign NameStore Call NameLoad NameLoad If NameLoad body For NameStore Call NameLoad NameLoad body Assign NameStore Num While CompareLt NameLoad NameLoad body Assign NameStore Call AttributeLoad NameLoad attr BinOpSub Num Call AttributeLoad NameLoad attr AugAssignAdd NameStore Call NameLoad BinOpDiv NameLoad NameLoad If CompareEq Call AttributeLoad NameLoad attr NameLoad NameLoad SubscriptLoad NameLoad Index NameLoad body Assign NameStore SubscriptLoad NameLoad Index NameLoad If CompareLt NameLoad NameLoad body Expr Call AttributeLoad NameLoad attr NameLoad NameLoad AugAssignAdd NameStore Num orelse For NameStore Call NameLoad BinOpSub NameLoad Num body Assign NameStore SubscriptLoad NameLoad Index NameLoad While CompareLt NameLoad NameLoad body Assign NameStore Call AttributeLoad NameLoad attr BinOpSub Num Call AttributeLoad NameLoad attr AugAssignAdd NameStore Call NameLoad BinOpDiv NameLoad NameLoad If CompareLt NameLoad NameLoad body Expr Call AttributeLoad NameLoad attr NameLoad NameLoad AugAssignAdd NameStore Num Return NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam NameParam NameParam NameParam defaults NameLoad NameLoad body Expr Str Return Call NameLoad BinOpMult ListLoad NameLoad NameLoad NameLoad NameLoad NameLoad NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam NameParam NameParam NameParam NameParam defaults NameLoad NameLoad body Expr Str If CompareGt NameLoad NameLoad body Raise Call AttributeLoad NameLoad attr Str Assign NameStore Num Assign NameStore ListLoad While NameLoad body Assign NameStore Call NameLoad Call AttributeLoad NameLoad attr NameLoad BinOpAdd BinOpDiv Call NameLoad NameLoad NameLoad Num If CompareLt NameLoad Num body Continue If CompareGtE BinOpAdd NameLoad NameLoad NameLoad body Expr Call AttributeLoad NameLoad attr BinOpSub NameLoad NameLoad Break AugAssignAdd NameStore NameLoad Expr Call AttributeLoad NameLoad attr NameLoad Return Call NameLoad NameLoad NameLoad NameLoad NameLoad NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str If CompareLt NameLoad Num body Raise Call AttributeLoad NameLoad attr Str If CompareLt NameLoad Num body Raise Call AttributeLoad NameLoad attr Str Assign NameStore Call AttributeLoad NameLoad attr For NameStore Call NameLoad NameLoad body Assign NameStore Call AttributeLoad NameLoad attr Call NameLoad BinOpMult NameLoad NameLoad BinOpAdd BinOpMult NameLoad NameLoad NameLoad Num Expr Call AttributeLoad NameLoad attr NameLoad Expr Call AttributeLoad NameLoad attr BinOpAdd BinOpMult NameLoad NameLoad Num BinOpMod BinOpMult BinOpAdd NameLoad Num NameLoad BinOpMult NameLoad NameLoad Return NameLoad decorator_list
N/A N/A Generators for classes of graphs used in studying social networks. N/A itertools N/A math N/A random N/A networkx nx N/A __author__ N/A N/A join N/A Ben Edwards (bedwards@cs.unm.edu) Aric Hagberg (hagberg@lanl.gov) Konstantinos Karakatsanis <dinoskarakas@gmail.com> N/A __all__ N/A caveman_graph connected_caveman_graph relaxed_caveman_graph random_partition_graph planted_partition_graph gaussian_random_partition_graph ring_of_cliques caveman_graph N/A N/A l k N/A N/A N/A Returns a caveman graph of `l` cliques of size `k`.

    Parameters
    ----------
    l : int
      Number of cliques
    k : int
      Size of cliques

    Returns
    -------
    G : NetworkX Graph
      caveman graph

    Notes
    -----
    This returns an undirected graph, it can be converted to a directed
    graph using :func:`nx.to_directed`, or a multigraph using
    ``nx.MultiGraph(nx.caveman_graph(l, k))``. Only the undirected version is
    described in [1]_ and it is unclear which of the directed
    generalizations is most useful.

    Examples
    --------
    >>> G = nx.caveman_graph(3, 3)

    See also
    --------

    connected_caveman_graph

    References
    ----------
    .. [1] Watts, D. J. 'Networks, Dynamics, and the Small-World Phenomenon.'
       Amer. J. Soc. 105, 493-527, 1999.
     N/A G N/A N/A nx empty_graph N/A l k N/A N/A G name N/A caveman_graph(%s,%s) N/A N/A l k k N/A N/A k 1 N/A N/A start N/A range 0 N/A l k k N/A N/A edges N/A N/A itertools combinations N/A range start N/A start k 2 N/A N/A N/A G add_edges_from edges N/A G N/A connected_caveman_graph N/A N/A l k N/A N/A N/A Returns a connected caveman graph of `l` cliques of size `k`.

    The connected caveman graph is formed by creating `n` cliques of size
    `k`, then a single edge in each clique is rewired to a node in an
    adjacent clique.

    Parameters
    ----------
    l : int
      number of cliques
    k : int
      size of cliques

    Returns
    -------
    G : NetworkX Graph
      connected caveman graph

    Notes
    -----
    This returns an undirected graph, it can be converted to a directed
    graph using :func:`nx.to_directed`, or a multigraph using
    ``nx.MultiGraph(nx.caveman_graph(l, k))``. Only the undirected version is
    described in [1]_ and it is unclear which of the directed
    generalizations is most useful.

    Examples
    --------
    >>> G = nx.connected_caveman_graph(3, 3)

    References
    ----------
    .. [1] Watts, D. J. 'Networks, Dynamics, and the Small-World Phenomenon.'
       Amer. J. Soc. 105, 493-527, 1999.
     N/A G N/A N/A nx caveman_graph l k N/A N/A G name N/A connected_caveman_graph(%s,%s) N/A l k N/A start N/A range 0 N/A l k k N/A N/A N/A N/A G remove_edge start N/A start 1 N/A N/A N/A G add_edge start N/A N/A start 1 N/A l k N/A G N/A relaxed_caveman_graph N/A N/A l k p seed N/A None N/A N/A Return a relaxed caveman graph.

    A relaxed caveman graph starts with `l` cliques of size `k`.  Edges are
    then randomly rewired with probability `p` to link different cliques.

    Parameters
    ----------
    l : int
      Number of groups
    k : int
      Size of cliques
    p : float
      Probabilty of rewiring each edge.
    seed : int,optional
      Seed for random number generator(default=None)

    Returns
    -------
    G : NetworkX Graph
      Relaxed Caveman Graph

    Raises
    ------
    NetworkXError:
     If p is not in [0,1]

    Examples
    --------
    >>> G = nx.relaxed_caveman_graph(2, 3, 0.1, seed=42)

    References
    ----------
    .. [1] Santo Fortunato, Community Detection in Graphs,
       Physics Reports Volume 486, Issues 3-5, February 2010, Pages 75-174.
       http://arxiv.org/abs/0906.0612
     N/A N/A N/A seed None N/A N/A N/A N/A random seed seed N/A G N/A N/A nx caveman_graph l k N/A nodes N/A list G N/A N/A G name N/A relaxed_caveman_graph (%s,%s,%s) N/A l k p N/A N/A u v N/A N/A G edges N/A N/A N/A N/A N/A random random p N/A N/A x N/A N/A random choice nodes N/A N/A N/A G has_edge u x N/A N/A N/A N/A N/A G remove_edge u v N/A N/A N/A G add_edge u x N/A G N/A random_partition_graph N/A N/A sizes p_in p_out seed directed N/A None False N/A N/A Return the random partition graph with a partition of sizes.

    A partition graph is a graph of communities with sizes defined by
    s in sizes. Nodes in the same group are connected with probability
    p_in and nodes of different groups are connected with probability
    p_out.

    Parameters
    ----------
    sizes : list of ints
      Sizes of groups
    p_in : float
      probability of edges with in groups
    p_out : float
      probability of edges between groups
    directed : boolean optional, default=False
      Whether to create a directed graph
    seed : int optional, default None
      A seed for the random number generator

    Returns
    -------
    G : NetworkX Graph or DiGraph
      random partition graph of size sum(gs)

    Raises
    ------
    NetworkXError
      If p_in or p_out is not in [0,1]

    Examples
    --------
    >>> G = nx.random_partition_graph([10,10,10],.25,.01)
    >>> len(G)
    30
    >>> partition = G.graph['partition']
    >>> len(partition)
    3

    Notes
    -----
    This is a generalization of the planted-l-partition described in
    [1]_.  It allows for the creation of groups of any size.

    The partition is store as a graph attribute 'partition'.

    References
    ----------
    .. [1] Santo Fortunato 'Community Detection in Graphs' Physical Reports
       Volume 486, Issue 3-5 p. 75-174. http://arxiv.org/abs/0906.0612
       http://arxiv.org/abs/0906.0612
        N/A N/A N/A seed None N/A N/A N/A N/A random seed seed N/A N/A N/A 0.0 p_in 1.0 N/A N/A N/A N/A nx NetworkXError p_in must be in [0,1] N/A N/A N/A 0.0 p_out 1.0 N/A N/A N/A N/A nx NetworkXError p_out must be in [0,1] N/A directed N/A N/A G N/A N/A nx DiGraph N/A N/A G N/A N/A nx Graph N/A N/A N/A G graph N/A partition N/A N/A n N/A sum sizes N/A N/A N/A G add_nodes_from N/A range n N/A next_group N/A N/A start 0 N/A group 0 N/A n sizes N/A N/A edges N/A N/A N/A u start N/A v start N/A N/A u v N/A N/A N/A N/A nx fast_gnp_random_graph n p_in directed directed edges N/A N/A N/A G add_edges_from edges N/A N/A N/A next_group update N/A N/A dict fromkeys N/A range start N/A start n N/A start n N/A N/A N/A N/A N/A G graph N/A partition append N/A set N/A range start N/A start n N/A group 1 N/A start n N/A N/A p_out 0 N/A N/A G N/A N/A p_out 1 N/A N/A n next_group N/A N/A targets N/A range N/A next_group N/A n N/A len G N/A N/A N/A G add_edges_from N/A zip N/A N/A n N/A len targets targets N/A directed N/A N/A N/A N/A G add_edges_from N/A zip targets N/A N/A n N/A len targets N/A G N/A lp N/A N/A math log N/A 1.0 p_out N/A n N/A len G N/A directed N/A N/A u N/A range n N/A N/A v 0 N/A N/A v n N/A N/A lr N/A N/A math log N/A 1.0 N/A N/A random random N/A v N/A int N/A lr lp N/A N/A N/A N/A next_group get v n N/A next_group N/A u N/A N/A v N/A next_group N/A u N/A N/A v n N/A N/A N/A N/A G add_edge u v N/A v 1 N/A N/A u N/A range N/A n 1 N/A N/A v N/A next_group N/A u N/A N/A v n N/A N/A lr N/A N/A math log N/A 1.0 N/A N/A random random N/A v N/A int N/A lr lp N/A N/A v n N/A N/A N/A N/A G add_edge u v N/A v 1 N/A G N/A planted_partition_graph N/A N/A l k p_in p_out seed directed N/A None False N/A N/A Return the planted l-partition graph.

    This model partitions a graph with n=l*k vertices in
    l groups with k vertices each. Vertices of the same
    group are linked with a probability p_in, and vertices
    of different groups are linked with probability p_out.

    Parameters
    ----------
    l : int
      Number of groups
    k : int
      Number of vertices in each group
    p_in : float
      probability of connecting vertices within a group
    p_out : float
      probability of connected vertices between groups
    seed : int,optional
      Seed for random number generator(default=None)
    directed : bool,optional (default=False)
      If True return a directed graph

    Returns
    -------
    G : NetworkX Graph or DiGraph
      planted l-partition graph

    Raises
    ------
    NetworkXError:
      If p_in,p_out are not in [0,1] or

    Examples
    --------
    >>> G = nx.planted_partition_graph(4, 3, 0.5, 0.1,seed=42)

    See Also
    --------
    random_partition_model

    References
    ----------
    .. [1] A. Condon, R.M. Karp, Algorithms for graph partitioning
        on the planted partition model,
        Random Struct. Algor. 18 (2001) 116-140.

    .. [2] Santo Fortunato 'Community Detection in Graphs' Physical Reports
       Volume 486, Issue 3-5 p. 75-174. http://arxiv.org/abs/0906.0612
     N/A N/A random_partition_graph N/A N/A k l p_in p_out seed directed N/A gaussian_random_partition_graph N/A N/A n s v p_in p_out directed seed N/A False None N/A N/A Generate a Gaussian random partition graph.

    A Gaussian random partition graph is created by creating k partitions
    each with a size drawn from a normal distribution with mean s and variance
    s/v. Nodes are connected within clusters with probability p_in and
    between clusters with probability p_out[1]

    Parameters
    ----------
    n : int
      Number of nodes in the graph
    s : float
      Mean cluster size
    v : float
      Shape parameter. The variance of cluster size distribution is s/v.
    p_in : float
      Probabilty of intra cluster connection.
    p_out : float
      Probability of inter cluster connection.
    directed : boolean, optional default=False
      Whether to create a directed graph or not
    seed : int
      Seed value for random number generator

    Returns
    -------
    G : NetworkX Graph or DiGraph
      gaussian random partition graph

    Raises
    ------
    NetworkXError
      If s is > n
      If p_in or p_out is not in [0,1]

    Notes
    -----
    Note the number of partitions is dependent on s,v and n, and that the
    last partition may be considerably smaller, as it is sized to simply
    fill out the nodes [1]

    See Also
    --------
    random_partition_graph

    Examples
    --------
    >>> G = nx.gaussian_random_partition_graph(100,10,10,.25,.1)
    >>> len(G)
    100

    References
    ----------
    .. [1] Ulrik Brandes, Marco Gaertler, Dorothea Wagner,
       Experiments on Graph Clustering Algorithms,
       In the proceedings of the 11th Europ. Symp. Algorithms, 2003.
     N/A N/A s n N/A N/A N/A N/A nx NetworkXError s must be <= n N/A assigned 0 N/A sizes N/A N/A True N/A N/A size N/A int N/A N/A random normalvariate s N/A N/A N/A float s v 0.5 N/A N/A size 1 N/A N/A N/A N/A N/A assigned size n N/A N/A N/A N/A sizes append N/A n assigned N/A N/A assigned size N/A N/A N/A sizes append size N/A N/A random_partition_graph sizes p_in p_out directed seed N/A ring_of_cliques N/A N/A num_cliques clique_size N/A N/A N/A Defines a "ring of cliques" graph.

    A ring of cliques graph is consisting of cliques, connected through single
    links. Each clique is a complete graph.

    Parameters
    ----------
    num_cliques : int
      Number of cliques
    clique_size : int
      Size of cliques

    Returns
    -------
    G : NetworkX Graph
      ring of cliques graph

    Raises
    ------
    NetworkXError
        If the number of cliques is lower than 2 or
        if the size of cliques is smaller than 2.

    Examples
    --------
    >>> G = nx.ring_of_cliques(8, 4)

    See Also
    --------
    connected_caveman_graph

    Notes
    -----
    The `connected_caveman_graph` graph removes a link from each clique to
    connect it with the next clique. Instead, the `ring_of_cliques` graph
    simply adds the link without removing any link from the cliques.
     N/A N/A num_cliques 2 N/A N/A N/A N/A nx NetworkXError A ring of cliques must have at least two cliques N/A N/A clique_size 2 N/A N/A N/A N/A nx NetworkXError The cliques must have at least two nodes N/A G N/A N/A nx Graph N/A i N/A range num_cliques N/A N/A edges N/A N/A itertools combinations N/A range N/A i clique_size N/A N/A i clique_size clique_size 2 N/A N/A N/A G add_edges_from edges N/A N/A N/A G add_edge N/A N/A i clique_size 1 N/A N/A N/A i 1 clique_size N/A num_cliques clique_size N/A G N/A