We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
import numpy as np from networkx import barabasi_albert_graph from causaldag import DAG
def directed_random_graph(nnodes, random_graph_model): edges = random_graph_model(nnodes).edges random_permutation = np.arange(nnodes) np.random.shuffle(random_permutation) arcs = [] for edge in edges: node1, node2 = edge node1_position = np.where(random_permutation == node1)[0][0] node2_position = np.where(random_permutation == node2)[0][0] if node1_position < node2_position: source = node1 endpoint = node2 else: source = node2 endpoint = node1 arcs.append((source, endpoint)) return DAG(nodes=set(range(nnodes)), arcs=arcs)
def directed_barbasi(nnodes, nattach): random_graph_model = lambda nnodes: barabasi_albert_graph(nnodes, nattach) return directed_random_graph(nnodes, random_graph_model)
The text was updated successfully, but these errors were encountered:
No branches or pull requests
import numpy as np
from networkx import barabasi_albert_graph
from causaldag import DAG
def directed_random_graph(nnodes, random_graph_model):
edges = random_graph_model(nnodes).edges
random_permutation = np.arange(nnodes)
np.random.shuffle(random_permutation)
arcs = []
for edge in edges:
node1, node2 = edge
node1_position = np.where(random_permutation == node1)[0][0]
node2_position = np.where(random_permutation == node2)[0][0]
if node1_position < node2_position:
source = node1
endpoint = node2
else:
source = node2
endpoint = node1
arcs.append((source, endpoint))
return DAG(nodes=set(range(nnodes)), arcs=arcs)
def directed_barbasi(nnodes, nattach):
random_graph_model = lambda nnodes: barabasi_albert_graph(nnodes, nattach)
return directed_random_graph(nnodes, random_graph_model)
The text was updated successfully, but these errors were encountered: