Skip to content

Commit

Permalink
Fixed easy linter issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
thijsvl committed Aug 20, 2024
1 parent 59d8294 commit 5ccfc57
Showing 1 changed file with 21 additions and 25 deletions.
46 changes: 21 additions & 25 deletions dgl_ptm/dgl_ptm/network/network_creation.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,24 @@
#!/usr/bin/env python
# coding: utf-8


import dgl
import networkx as nx
import random
import torch

# network_creation - Creates the network between the initialized nodes using edges from DGL

def network_creation(num_agents, method, **kwargs):
'''
network_creation - Creates the graph network for the model using the barabasi albert model from networkx
Args:
num_agents: Number of agent nodes
method: Current implemented methods include:
barabasi_albert model: This method takes the following possible keyword arguments,
seed: random seed for networkx barabasi_albert_graph function
new_node_edges: number of edges to create for each new node
Return:
agent_graph: Created agent_graph as per the chosen method
'''
"""network_creation - Creates the graph network for the model using the barabasi albert model from networkx
Args:
num_agents: Number of agent nodes
method: Current implemented methods include:
barabasi_albert model: This method takes the following possible keyword arguments,
seed: random seed for networkx barabasi_albert_graph function
new_node_edges: number of edges to create for each new node
Return:
agent_graph: Created agent_graph as per the chosen method
"""
if (method == 'barabasi-albert'):
if 'seed' in kwargs.keys():
seed = kwargs['seed']
Expand All @@ -40,19 +38,17 @@ def network_creation(num_agents, method, **kwargs):
return agent_graph

def barabasi_albert_graph(num_agents, new_node_edges=1, seed=1):
'''
Creates a network graph for user-defined number of agents using the barabasi
albert model function from networkx.
Args:
num_agents = Number of agent nodes
new_node_edges = Number of edges to create for each new node
seed = random seed for function
"""Creates a network graph for user-defined number of agents using the barabasi
albert model function from networkx.
Return:
agent_graph: Created agent_graph as per the chosen method
'''
Args:
num_agents = Number of agent nodes
new_node_edges = Number of edges to create for each new node
seed = random seed for function
Return:
agent_graph: Created agent_graph as per the chosen method
"""
#Create graph using networkx function for barabasi albert graph
networkx_graph = nx.barabasi_albert_graph(n=num_agents, m=new_node_edges, seed=seed)
barabasi_albert_coo = nx.to_scipy_sparse_array(networkx_graph,format='coo')
Expand Down

0 comments on commit 5ccfc57

Please sign in to comment.