This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from networkx.utils import random_weighted_sample | |
def barabasi_albert_graph_rwc(n, m, seed=None): | |
if m < 1 or m >=n: | |
raise nx.NetworkXError("Barabási–Albert network must have m >= 1" | |
" and m < n, m = %d, n = %d" % (m, n)) | |
if seed is not None: | |
random.seed(seed) | |
# Add m initial nodes (m0 in barabasi-speak) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def from_biadjacency_matrix(A,create_using=None): | |
import numpy as np | |
kind_to_python_type={'f':float, | |
'i':int, | |
'u':int, | |
'b':bool, | |
'c':complex, | |
'S':str, | |
'V':'void'} | |
try: # Python 3.x |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from networkx import Graph | |
from networkx.exception import NetworkXException, NetworkXError | |
import networkx.convert as convert | |
class Tree(Graph): | |
""" A free (unrooted) tree.""" | |
def __init__(self, data=None, **attr): | |
Graph.__init__(self, **attr) | |
if data is not None: | |
convert.to_networkx_graph(data, create_using=self) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
"""Implementation of the Wright, Richmond, Odlyzko and McKay (WROM) | |
algorithm for the enumeration of all non-isomorphic free trees of a | |
given order. Rooted trees are represented by level sequences, i.e., | |
lists in which the i-th element specifies the distance of vertex i to | |
the root.""" | |
import sys |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import networkx as nx | |
print nx.__version__ | |
g = nx.gnp_random_graph(1000,0.01) | |
nx.write_gml(g, 'foo.gml') | |
for i in range(10000): | |
g = nx.read_gml('foo.gml') | |
print g.number_of_nodes(), g.number_of_edges() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
graph [ | |
node [ | |
id 13595 | |
label 164966 | |
bytesInAsClient 0 | |
bytesOutAsServer 0 | |
ip "10.0.0.1" | |
start_time "2013-09-08T13:24:28Z" | |
Class "Device" | |
coid "11111" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
import networkx as nx | |
from contextlib import contextmanager | |
@contextmanager | |
def hidden_nodes(G, nodes=None): | |
import types | |
if nodes is None: | |
nodes = [] | |
def successors_iter(G,n): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import networkx as nx | |
from contextlib import contextmanager | |
@contextmanager | |
def hidden(G, nodes=None, edges=None): | |
if nodes is None: | |
nodes = [] | |
if edges is None: | |
edges = [] | |
hidden_nodes = [(u,G.node[u]) for u in nodes] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NetworkX does not appear to be in the venv: /home/aric/Software/hagberg-networkx/networkx/__init__.pyc | |
Do you use setupegg.py develop? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.1" encoding="UTF-8" standalone="no"?> | |
<graphml xmlns="http://graphml.graphdrawing.org/xmlns" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:y="http://www.yworks.com/xml/graphml" xsi:schemaLocation="http://graphml.graphdrawing.org/xmlns http://www.yworks.com/xml/schema/graphml/1.1/ygraphml.xsd"> | |
<VersionInfo createdBy="Maltego Radium" subtitle="" version="3.2.1.3453"/> | |
<key for="graphml" id="d0" yfiles.type="resources"/> | |
<key for="port" id="d1" yfiles.type="portgraphics"/> | |
<key for="port" id="d2" yfiles.type="portgeometry"/> | |
<key for="port" id="d3" yfiles.type="portuserdata"/> | |
<key attr.name="MaltegoEntity" for="node" id="d4" attr.type="string"/> | |
<key for="node" id="d5" yfiles.type="nodegraphics"/> | |
<key attr.name="MaltegoLink" for="edge" id="d6" attr.type="string"/> |
NewerOlder