Esempio n. 1
0
def plot_network2(network):
    """Function that plots the network of topics.
        It mainly relies on webweb: https://github.com/dblarremore/webweb

    Args:
        network (dictionary): computed network.


    Returns:
        
        """

    G = nx.Graph()
    for node in network["nodes"]:
        G.add_node(node["label"])
        G.nodes[node["label"]]['isPaper'] = False

    G.nodes["paper"]['isPaper'] = True

    for edge in network["edges"]:
        G.add_edge(edge["source"],
                   edge["target"],
                   kind=edge["kind"],
                   style='dashed')

    # create the web
    web = Web(nx_G=G)

    web.display.showNodeNames = True
    web.display.colorBy = 'isPaper'

    web.show()
Esempio n. 2
0
def webweb_plot(g, coms):
    # create dictionary of node:community pairs for quick look up
    print('Plotting with WebWeb')
    coms_dict = {}
    for i in range(len(coms)):
        for c in coms[i]:
            # this is to control for string reformatting R did...
            if c[0:3] == 'HP.':
                c = c.replace('.', ':')
            coms_dict[c] = i

    # create metadata labels for plotting
    labels = {}
    for i in g.nodes:
        name = g.nodes[i]['Name']
        if name in coms_dict.keys():
            labels[i] = {
                'isGene': g.nodes[i]['Type'] == 'HPO',
                'name': coms_dict[name],
                'Community': coms_dict[name]
            }
    w = Web(adjacency=nx.to_numpy_array(g), display={'nodes': labels})
    # set some default visualization settings in webweb
    w.display.charge = 50
    w.display.sizeBy = 'degree'
    # genes will be colored green
    w.display.colorBy = 'Community'
    w.display.charge = 10
    w.display.linkLength = 5
    w.display.gravity = 0.5
    w.show()
Esempio n. 3
0
def net_vis(ld_file, loci_file):
    web = Web(title='webweb')

    loci_path = os.path.abspath(loci_file)
    loci = pandas.read_csv(loci_path)

    def get_ef(l):
        q = 'locus ==' + str(l)
        r = loci.query(q)
        return r.iloc[0]['ef']

    def get_chr(l):
        q = 'locus ==' + str(l)
        r = loci.query(q)
        return r.iloc[0]['chromo']

    path = os.path.abspath(ld_file)
    df = pandas.read_csv(path)

    gens = df['generation'].unique()

    thres = 0.005

    max_locus = df['locus2'].max()
    metadata = {
        'ef': {
            'values': [get_ef(x) for x in range(max_locus)]
        },
        'chromo': {
            'values': [get_chr(x) for x in range(max_locus)]
        },
    }

    for gen in gens:
        q = 'generation == ' + str(gen)
        this_gen = df.query(q)
        max = this_gen['D'].max()

        edge_list = []

        for row in this_gen.itertuples():
            L1 = row[2]
            L2 = row[3]
            D = row[4]
            Gen = row[1]

            if D > thres:
                edge = [L1, L2, 0.1]
                edge_list.append(edge)
            else:
                edge = [L1, L2, 0]
                edge_list.append(edge)

        web.networks.webweb.add_layer(adjacency=edge_list, metadata=metadata)
    #web.display.scaleLinkWidth = True
    web.show()
Esempio n. 4
0
def plot_single_community_webweb(g, coms, com):
    print('Plotting with WebWeb')

    # create dictionary of node:community pairs for quick look up
    coms_dict = {}
    for i in range(len(coms)):
        for c in coms[i]:
            coms_dict[c] = i

    # get the indexes of the nodes in the community of interest
    com_indexes = []
    for i in g.nodes:
        name = g.nodes[i]['Name']
        if name in coms_dict.keys():
            if coms_dict[name] == com:
                com_indexes.append(i)

    # get a subset of the grapha that is just the community of interest
    subgraph = g.subgraph(com_indexes)

    # create a name mapping to relabel subgraph nodes starting at one
    name_mapping = {}
    node_count = 0
    for i in subgraph.nodes:
        print(i)
        name_mapping[i] = node_count
        node_count += 1

    # relabel subgraph nodes starting at one
    subgraph = nx.relabel_nodes(subgraph, name_mapping)

    # create labels for the nodes for use in webweb
    labels = {}
    for i in subgraph.nodes:
        name = subgraph.nodes[i]['Name']
        if name in coms_dict.keys():
            if coms_dict[name] == com:
                labels[i] = {
                    'isGene': subgraph.nodes[i]['Type'] == 'HPO',
                    'name': name,
                    'Community': coms_dict[name]
                }

    # plot it using webweb
    w = Web(adjacency=nx.to_numpy_array(subgraph), display={'nodes': labels})
    # set some default visualization settings in webweb
    w.display.charge = 50
    w.display.sizeBy = 'degree'
    w.display.colorBy = 'isGene'
    w.display.charge = 20
    w.display.linkLength = 50
    w.display.gravity = 0.1
    w.show()
Esempio n. 5
0
def display_with_webweb(graph, section_sequence):
    print("Displaying graph using webweb...")
    web = Web(title='book')
    web.display.colorBy = 'degree'
    web.display.sizeBy = 'degree'
    web.display.l = 60
    web.display.c = 120
    web.display.scaleLinkWidth = True
    for G in graph.graph_by_sections(section_sequence,
                                     aggregate=True,
                                     decay_weights=True,
                                     stability=40):
        web.networks.book.add_layer(nx_G=G)
    web.show()
Esempio n. 6
0
def visual_graph(all_bands):
    edge_list = []

    b = []
    i = 0
    for band_id in all_bands:
        i +=1
        # if i > 100:
        #     break
        if all_bands[band_id]["is_dup"]:
            continue
        for to in all_bands[band_id]["in_conns"]:
            if all_bands[to]["is_dup"]:
                to = all_bands[to]["link_to"]
            edge_list.append([band_id, to])
            edge_list.append([to, band_id])
        if set(all_bands[band_id]["genres"]) == {"rock"}:
            group = 'R'
        elif set(all_bands[band_id]["genres"]) == {"country"}:
            group = 'C'
        elif set(all_bands[band_id]["genres"]) == {"metal"}:
            group = "M"
        elif set(all_bands[band_id]["genres"]) == {"rock", "country"}:
            group = "R+C"
        elif set(all_bands[band_id]["genres"]) == {"rock", "metal"}:
            group = "R+M"
        elif set(all_bands[band_id]["genres"]) == {"country", "metal"}:
            group = "C+M"
        elif set(all_bands[band_id]["genres"]) == {"rock", "country", "metal"}:
            group = "R+C+M"
        else:
            raise Exception("Band with unspecified group")
        b.append([band_id, group])

    web = Web(title='sbm_demo',
              # assign its edgelist
              adjacency=edge_list,
              # give it the community metadata
              nodes={i: {'Genre': g} for i, g in b},
              # display={"metadata": {'Genre': {'values': ["R", "C", "M", "R+C", "R+M", "C+M", "R+C+M"]}}}
    )
    web.display.colorBy = 'Genre'
    web.show()
def visualizePassingNetworks(visTitle, visInfoList):
    # Visualization Parameters
    width = 800
    height = 480
    padding = 50

    #field dimensions in yards
    fieldLength = 120
    fieldWidth = 75
    # instantiate webweb
    web = Web(title=visTitle)

    for item in visInfoList:
        passing, libPlayers = PassingUtilities.createPassingListAndLib(item[0])
        if len(passing) != 0:
            A = PassingUtilities.createAdjacencyMatrix(passing, libPlayers)
            displayInfo = createMetaData(libPlayers, width, height, padding,
                                         fieldLength, fieldWidth)

            web.networks.__dict__[item[1]] = webweb.webweb.Network(
                adjacency=A, metadata=displayInfo)

    web.display.charge = 500
    web.display.linkLength = 200
    web.display.linkStrength = 0.5
    web.display.gravity = .1
    web.display.radius = 10
    web.display.scaleLinkOpacity = True
    web.display.colorBy = 'team'
    web.display.scaleLinkWidth = True
    web.display.sizeBy = 'strength'
    web.display.showNodeNames = True
    web.display.showLegend = True
    web.display.colorPalette = 'Dark2'
    web.display.freezeNodeMovement = True
    web.display.width = width
    web.display.height = height
    web.display.attachWebwebToElementWithId = 'soccer-vis'
    web.show()
Esempio n. 8
0
def make_network(papers, people, software):
    nodes = defaultdict(dict)
    edges = []
    for paper in papers:
        title = paper['title']
        nodes[title] = {'name': title, 'kind': 'paper'}

        for name in [clean_name(n) for n in paper['authors']]:
            nodes[name]['name'] = name
            nodes[name]['kind'] = 'collaborator'
            edges.append([title, name])

    for software_project in software:
        title = software_project['title']
        nodes[title] = {'name': title, 'kind': 'software'}
        for name in [clean_name(n) for n in software_project['authors']]:
            nodes[name]['name'] = name
            nodes[name]['kind'] = 'collaborator'
            edges.append([title, name])

    dan = people['dan']
    for person in people['phd_students']:
        name = clean_name(person['name'])
        nodes[name]['name'] = name
        nodes[name]['kind'] = 'phd student'
        edges.append([dan['name'], name])

    for person in people['undergraduate_students']:
        name = clean_name(person['name'])
        nodes[name]['name'] = name
        nodes[name]['kind'] = 'undergraduate student'
        edges.append([dan['name'], name])

    nodes[dan['name']]['kind'] = 'dbl'
    web = Web(adjacency=edges, nodes=dict(nodes))
    web.display.colorBy = 'kind'
    web.display.colorPalette = 'Dark2'
    web.display.hideMenu = True
    web.display.showLegend = False

    WEBWEB_JSON_PATH.write_text(web.json)
    reader = csv.reader(f, delimiter=';')
    next(reader, None)  # skip the input CSV headers [1][2]
    pageLinks = list(reader)

nodes = {}

df = pd.read_csv(space_key + "_pageHistories.csv", sep=';')
for i in df[['contributor_id',
             'contributor_name']].drop_duplicates().values.tolist():
    nodes[i[0]] = {'name': i[1], 'type': 'contributor'}

for j in df['pageId'].drop_duplicates().values.tolist():
    nodes[j] = {'type': 'page'}

web = Web(
    adjacency=pageLinks,
    title=space_key,
    display={'nodes': nodes},
)

#web.display.charge = 250
#web.display.linkLength = 50
web.display.height = 1024
web.display.width = 1280
web.display.colorBy = 'type'
web.display.sizeBy = 'degree'
#web.display.hideMenu = True
#web.display.showNodeNames = True

#web.show()
web.save(space_key + '_pageGraph.html')
Esempio n. 10
0
from webweb import Web

# Instantiate webweb object
web = Web([[0, 1, 5], [1, 2, 20], [2, 3, .2], [3, 4, 70], [4, 5, 100]])

web.display.scaleLinkOpacity = True

# show the visualization
web.show()
Esempio n. 11
0
from webweb import Web

# Instantiate webweb object
web = Web([[0, 1], [1, 2], [2, 3], [3, 4], [4, 5]])

# hide webweb's menus
web.display.hideMenu = True

# show the visualization
web.show()
Esempio n. 12
0
from webweb import Web
import networkx as nx

# webweb'll display a metadata attribute as binary if every node's value for
# that attribute is either True or False.
G = nx.Graph()
G.add_edges_from([['Dan', 'Hunter'], ['Brian', 'Hunter'], ['Carl', 'Hunter'],
                  ['Carl', 'Brian']])

G.nodes['Dan']['wearsGlasses'] = True
G.nodes['Hunter']['wearsGlasses'] = True
G.nodes['Brian']['wearsGlasses'] = True
G.nodes['Carl']['wearsGlasses'] = False

# `True` values will be "big" and `False` values small, but if we wanted the
# opposite, we could do the following:
# web.display.invertBinarySizes = True

# create the web
web = Web(nx_G=G)

# use the 'wearsGlasses' to compute node sizes
web.display.sizeBy = 'wearsGlasses'

# open the browser with the result
web.draw()
Esempio n. 13
0
from webweb import Web

web = Web(
    adjacency=[['Dan', 'Hunter'], ['Brian', 'Hunter'], ['Carl', 'Hunter'],
               ['Carl', 'Brian']],
    display={
        'nodes': {
            'Dan': {
                'wearsGlasses': True,
            },
            'Hunter': {
                'wearsGlasses': True,
            },
            'Brian': {
                'wearsGlasses': True,
            },
            'Carl': {
                'wearsGlasses': False,
            },
            'Tzu-Chi': {},
        },
        'metadata': {
            'wearsContacts': {
                'values': [True, False, True, False, False],
            }
        }
    },
)

# use the 'wearsGlasses' to compute node sizes
web.display.sizeBy = 'wearsGlasses'
Esempio n. 14
0
from webweb import Web

# Instantiate webweb object
web = Web(
    [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5]],
    display={
        'metadata': {
            'emotion': {
                'values': ['happy', 'sad', 'angry', 'sad', 'happy', 'sad']
            }
        }
    })

# use the 'emotion' attribute to color nodes
web.display.colorBy = 'emotion'

# show the visualization
web.show()
Esempio n. 15
0
    population = record[13].replace('","', '    ')

    NewList = []
    if GeneName in record[2]:
        NewList.append(Gene)
        NewList.append(SNP)
    Network.append(NewList)

    NewList = []
    if GeneName in record[2]:
        NewList.append(SNP)
        NewList.append(disease)
    Network.append(NewList)

    NewList = []
    if GeneName in record[2]:
        NewList.append(disease)
        NewList.append(drug)
    Network.append(NewList)

    NewList = []
    if GeneName in record[2]:
        NewList.append(drug)
        NewList.append(Annotations)
    Network.append(NewList)

Network = [x for x in Network if x != []]
from webweb import Web
edge_list = Network
Web(edge_list).show()
Esempio n. 16
0
from webweb import Web

# create the network
adjacency_list = [["Dan", "Hunter"], ["Dan", "Tzu-Chi"], ["Hunter", "Steve"]]

# create the web
web = Web(adjacency_list)

# open the browser with the result
web.draw()
Esempio n. 17
0
def make_network(data):
    nodes = defaultdict(dict)
    edges = []

    all_edges = []
    interests = data["areas"]["topics"]
    projects = data["projects"]["projects"]
    project_areas = set()
    for project in projects:
        name = project["name"]
        nodes[name] = {"name": name, "kind": "Project"}
        for area in project["areas"]:
            all_edges.append([name, area])
            project_areas.add(area)
    for interest in interests:
        area = interest["area"]
        # if area not in project_areas:
        #     continue
        nodes[area] = {"name": area, "kind": interest["kind"]}
        if not interest["related"]:
            continue
        for related in interest["related"]:
            all_edges.append([area, related])

    # Get only unique edges
    for edge in all_edges:
        if edge in edges or [edge[1], edge[0]] in edges:
            continue
        edges.append(edge)

    for node in nodes:
        kind = nodes[node]['kind']
        size = 1
        # if kind == 'Theory':
        #     size = 1.5
        # elif kind == 'Application':
        #     size = 1.25

        nodes[node]['size'] = size
        nodes[node]['color'] = KIND_TO_COLOR_MAP[kind]

    web = Web(adjacency=edges, nodes=dict(nodes))
    web.display.sizeBy = 'size'
    web.display.colorBy = 'color'
    web.display.hideMenu = True
    web.display.showLegend = False
    web.display.gravity = 1e-5
    web.display.charge = 500
    web.display.width = 400
    web.display.height = 400
    web.display.scaleLinkOpacity = True
    web.display.scaleLinkWidth = True
    web.display.scales = {
        'nodeSize': {
            'min': 0.65,
            'max': 1.1,
        }
    }

    WEBWEB_JSON_PATH.write_text(web.json)
    web.show()
Esempio n. 18
0
def make_network(data):
    nodes = defaultdict(dict)
    edges = []

    dan = data['people']['people'][0]['name']

    for category in data['papers']['categories']:
        for paper in category['pubs']:
            title = paper['title']
            nodes[title] = {
                'name': title,
                'kind': 'paper'
            }

            if 'links' in paper:
                nodes[title]['url'] = paper['links'][0]['url']

            for name in paper['authors']:
                if name == dan:
                    continue

                nodes[name]['name'] = name

                nodes[name]['kind'] = 'collaborator'

                for person in data['people']['collaborators']:
                    if person['name'] == name:
                        if person.get('url'):
                            nodes[name]['url'] = person['url']
                            break

                edges.append([title, name])

    for project in data['code']['repos']:
        title = project['title']
        nodes[title] = {
            'name': title,
            'kind': 'code'
        }
        for name in project['authors']:
            if name == dan:
                continue

            nodes[name]['name'] = name
            nodes[name]['kind'] = 'collaborator'

            edges.append([title, name])

    for project in data['extra']['projects']:
        project_name = project['name']
        nodes[project_name] = {
            'name': project_name,
            'kind': 'code'
        }

        if project.get('url'):
            nodes[project_name]['url'] = project['url']

        for name in project['people']:
            if name == dan:
                continue
            edges.append([project_name, name])

    for person in data['people']['people']:
        name = person['name']
        if name == dan:
            continue

        title = person['title'].lower()

        nodes[name]['name'] = name
        nodes[name]['kind'] = 'lab member'

        url = person.get('url')

        if url and url != '/':
            nodes[name]['url'] = url

    for node in nodes:
        kind = nodes[node]['kind']
        size = 1
        if kind == 'lab member':
            size = 1.5
        elif kind == 'collaborator':
            size = 1.25

        nodes[node]['size'] = size
        nodes[node]['color'] = KIND_TO_COLOR_MAP[kind]

    web = Web(adjacency=edges, nodes=dict(nodes))
    web.display.sizeBy = 'size'
    web.display.colorBy = 'color'
    web.display.hideMenu = True
    web.display.showLegend = False
    web.display.gravity = 0.4
    web.display.width = 400
    web.display.height = 400
    web.display.scaleLinkOpacity = True
    web.display.scaleLinkWidth = True
    web.display.scales = {
        'nodeSize': {
            'min': 0.65,
            'max': 1.1,
        }
    }

    WEBWEB_JSON_PATH.write_text(web.json)
Esempio n. 19
0
from webweb import Web

# Instantiate webweb object
web = Web(title='web1', adjacency=[[0, 1]])

web.networks.web2(adjacency=[[0, 1], [1, 2]])

web.display.networkName = "web2"

# show the visualization
web.show()
Esempio n. 20
0
# define the node names and a hunger metadata attribute to appear in all networks
web = Web(
    display={
        'nodes' : {
            0 : {
                'name' : 'dane',
                'hunger' : 4,
            },
            1 : {
                'name' : 'sebastian',
                'hunger' : 9,
            },
            2 : {
                'name' : 'manny',
                'hunger' : 2,
            },
            3 : {
                'name' : 'brock',
                'hunger' : 4,
            },
            4 : {
                'name' : 'ted',
                'hunger' : 12.1,
            },
            5 : {
                'name' : 'donnie',
                'hunger' : 5,
            },
        }
    },
)
Esempio n. 21
0
from webweb import Web

# Instantiate webweb object
web = Web([[0, 1], [1, 2], [2, 3], [3, 4], [4, 5]], display={
    'metadata' : {
        'happiness' : {
            'values' : [5, 10, 7, 8, 1, 3],
        }

    }
})

# use the 'happiness' attribute to size nodes
web.display.sizeBy = 'happiness'

# show the visualization
web.show()
Esempio n. 22
0
G.nodes[1]['cooperativity'] = 'low'
G.nodes[1]['alphabeticallity'] = 1

G.nodes[2]['cooperativity'] = 'medium'
G.nodes[2]['alphabeticallity'] = 2

# if the set of a metadata attribute's values contains strings (like
# 'cooperativity' here), webweb'll display it as a categorical variable.

# if that set contains numbers (like 'alphabeticallity' here), you should tell
# webweb how to display it by adding that metadata attribute name to the
# `metadataInfo` key to the `display` attribute with an array under
# `categories`; a node's value for this metadata attribute should be an index
# into this array.
web = Web(nx_G=G,
          display={
              'metadataInfo': {
                  'alphabeticallity': {
                      'categories': ['A-Z', 'a-z', 'W+'],
                  }
              },
          })

# we'll compute node color by the `alphabeticallity` metadata attribute
# (categorical metadata can't be used to compute node sizes)
web.display.colorBy = 'alphabeticallity'

# open the browser with the result
web.draw()
Esempio n. 23
0
from webweb import Web

# Instantiate webweb object
web = Web([[0, 1], [0, 2], [0, 3], [0, 4], [0, 5]])

# size and color by degree
web.display.sizeBy = 'degree'
web.display.colorBy = 'degree'

# hide webweb's legend (it defaults to being shown)
web.display.showLegend = False

# show the visualization
web.show()
Esempio n. 24
0
from webweb import Web

# make a network from an adjacency matrix
adjacency_matrix = [
    [0, 1, 0, 0],
    [1, 0, 1, 0],
    [0, 1, 0, 1],
    [0, 0, 1, 0],
]

# webweb'll guess whether the adjacency you've given it is a list or a matrix,
# but if you're pass it a matrix with fewer than 4 nodes, it'll think it's
# an adjacency list unless you put it in it's place like so: 
# web = Web(adjacency_matrix, adjacency_type='matrix')
web = Web(adjacency_matrix)

# create the web
web = Web(adjacency_matrix)

# open the browser with the result
web.draw()
Esempio n. 25
0
from webweb import Web
import webweb
import json
import numpy
import networkx as nx
import numpy as np
import matplotlib.pyplot as plt
import PassingUtilities
import WebWebUtilities

filenames = ["19714.json", "22921.json", "22924.json", "22943.json"]

# instantiate webweb
web = Web(title="World Cup Soccer Data")

for name in filenames:
    passing, libPlayers = PassingUtilities.createPassingListAndLib(name)
    A = PassingUtilities.createAdjacencyMatrix(passing, libPlayers)
    displayInfo = WebWebUtilities.createMetaData(libPlayers, 1000, 600, 50,
                                                 120, 75)

    web.networks.__dict__[name] = webweb.webweb.Network(adjacency=A,
                                                        metadata=displayInfo)

web.display.charge = 500
web.display.linkLength = 200
web.display.linkStrength = 0.5
web.display.gravity = .1
web.display.colorBy = 'team'
web.display.scaleLinkWidth = True
web.display.sizeBy = 'strength'
Esempio n. 26
0
from webweb import Web

web = Web(
    adjacency=[[0, 1], [1, 2]],
    display={
        'nodes': {
            0: {
                'name': 'Huberg',
            },
            1: {
                'name': 'Pierot',
            },
            2: {
                'name': 'Slartibertfast',
            },
        },
    },
)

web.display.showNodeNames = True

# show the visualization
web.show()
Esempio n. 27
0
from webweb import Web
import networkx as nx

# webweb'll display a metadata attribute as binary if every node's value for
# that attribute is either True or False.
G = nx.Graph()
G.add_edges_from([['Dan', 'Hunter'], ['Brian', 'Hunter'], ['Carl', 'Hunter'],
                  ['Carl', 'Brian']])

G.nodes['Dan']['wearsGlasses'] = True
G.nodes['Hunter']['wearsGlasses'] = True
G.nodes['Brian']['wearsGlasses'] = True
G.nodes['Carl']['wearsGlasses'] = False

# `True` values will be "big" and `False` values small, but if we wanted the
# opposite, we could do the following:
# web.display.invertBinarySizes = True

# create the web
web = Web(nx_G=G)

# use the 'wearsGlasses' to compute node sizes
web.display.sizeBy = 'wearsGlasses'

# show the visualization
web.show()
Esempio n. 28
0
from webweb import Web

# Instantiate webweb object
web = Web([[0, 1], [1, 2], [2, 3], [3, 4], [4, 5]], display={
    'metadata' : {
        'isHappy' : {
            'values' : [True, False, False, True, True, False],
        }

    }
})

# use the 'isHappy' attribute to size nodes
web.display.sizeBy = 'isHappy'

# invert the sizes used for `False` and `True` (make `False` big and `True` small)
web.display.invertBinarySizes = True

# show the visualization
web.show()
g = nx.subgraph(G, nodes)

display = {
    'nodes': {
        str(i): {
            'name': node,
            'deg': G.degree(node),
            'related': node in terms_to_remove,
            'node_count': node_counts[node]
        }
        for i, node in enumerate(g.nodes())
    }
}

web = Web(nx.to_numpy_array(g), display=display)
web.display.colorBy = 'related'
web.display.sizeBy = 'deg'
web.display.showNodeNames = True
web.display.linkLength = 100
web.display.charge = 300
web.display.radius = 10
web.show()

keys = list(node_counts.keys())
filtered_counts = [
    node_counts[key] for key in keys if node_counts[key] > 50 and key != 'CFTR'
]
filtered_keys = [
    key for key in keys if node_counts[key] > 50 and key != 'CFTR'
]
Esempio n. 30
0
from webweb import Web
import random

web = Web(
    title='oroboros',
    adjacency=[[0, 1], [1, 2], [2, 3]],
    nodes={
        0 : { 'isHead' : True },
        1 : { 'isHead' : False },
        2 : { 'isHead' : False },
        3 : { 'isHead' : False },
    },
)

# oroboros begins chompin'
web.networks.oroboros.add_layer(
    adjacency=[[0, 1], [1, 2], [2, 3], [3, 0]],
    nodes={
        0 : { 'isHead' : True },
        1 : { 'isHead' : False },
        2 : { 'isHead' : False },
        3 : { 'isHead' : False },
    },
)

web.networks.oroboros.add_layer(
    adjacency=[[0, 1], [1, 2], [2, 0]],
    nodes={
        0 : { 'isHead' : True },
        1 : { 'isHead' : False },
        2 : { 'isHead' : False },