Skip to content

Commit

Permalink
added add_clique method
Browse files Browse the repository at this point in the history
  • Loading branch information
IngoScholtes committed Oct 5, 2018
1 parent 5625d5a commit 5704d99
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions pathpy/classes/network.py
Expand Up @@ -24,6 +24,7 @@
# Web: http://www.ingoscholtes.net
import collections as _co
import copy
import itertools

import numpy as _np

Expand Down Expand Up @@ -375,6 +376,25 @@ def remove_edge(self, source, target):
del self.edges[(source, target)]


def add_clique(self, node_list, **edge_attributes):
r"""
Adds a fully connected clique to the network. This will
automatically create all edges between all pairs of nodes
(without self-loops). Depending on the network type
edges will be directed or undirected.
Parameters
----------
node_list: iterable
the list of nodes for which all pairs will be connected
edge_attributes: dict
edge attributes that will be assigned to all generated edges
"""
for v, w in itertools.combinations(node_list, 2):
self.add_edge(v, w, **edge_attributes)



def add_edge(self, v, w, **edge_attributes):
r"""
Adds an edge to a network and assigns arbitrary
Expand Down

0 comments on commit 5704d99

Please sign in to comment.