__init__.py 38.6 KB
Newer Older
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
    ...               output="price-network-broader.png")
    <...>

    .. image:: price-network.png
    .. image:: price-network-broader.png

    Price networks with :math:`N=10^5` nodes. **Left:** :math:`c=1`, **Right:**
    :math:`c=0.1`. The colors represent the order in which vertices were
    added.

    References
    ----------

    .. [yule] Yule, G. U. "A Mathematical Theory of Evolution, based on the
       Conclusions of Dr. J. C. Willis, F.R.S.". Philosophical Transactions of
       the Royal Society of London, Ser. B 213: 21–87, 1925,
Tiago Peixoto's avatar
Tiago Peixoto committed
1017
       :doi:`10.1098/rstb.1925.0002`
1018
1019
1020
    .. [price] Derek De Solla Price, "A general theory of bibliometric and other
       cumulative advantage processes", Journal of the American Society for
       Information Science, Volume 27, Issue 5, pages 292–306, September 1976,
Tiago Peixoto's avatar
Tiago Peixoto committed
1021
       :doi:`10.1002/asi.4630270505`
1022
    .. [barabasi-albert] Barabási, A.-L., and Albert, R., "Emergence of
Tiago Peixoto's avatar
Tiago Peixoto committed
1023
1024
       scaling in random networks", Science, 286, 509, 1999,
       :doi:`10.1126/science.286.5439.509`
1025
1026
    .. [dorogovtsev-evolution] S. N. Dorogovtsev and J. F. F. Mendes, "Evolution
       of networks", Advances in Physics, 2002, Vol. 51, No. 4, 1079-1187,
Tiago Peixoto's avatar
Tiago Peixoto committed
1027
       :doi:`10.1080/00018730110112519`
1028
1029
1030
1031
1032
1033
    """

    if c is None:
        c = 1 if directed else 0

    if seed_graph is None:
1034
1035
1036
        g = Graph(directed=directed)
        if c > 0:
            g.add_vertex()
1037
        else:
1038
1039
            g.add_vertex(2)
            g.add_edge(g.vertex(1), g.vertex(0))
1040
1041
1042
1043
1044
1045
        N -= g.num_vertices()
    else:
        g = seed_graph
    seed = numpy.random.randint(0, sys.maxint)
    libgraph_tool_generation.price(g._Graph__graph, N, gamma, c, m, seed)
    return g