Commit 710070d3 authored by dirk.wintergruen's avatar dirk.wintergruen
Browse files

logging added

parent 885080f1
...@@ -5,7 +5,8 @@ Some helpers to plot the networks with plotly (https://plot.ly) ...@@ -5,7 +5,8 @@ Some helpers to plot the networks with plotly (https://plot.ly)
import plotly.graph_objs as go import plotly.graph_objs as go
import numpy as np import numpy as np
import igraph import igraph
import logging
logger = logging.getLogger(__name__)
def \ def \
createSizeFromFunc(gr: igraph.Graph, func: str = "betweenness", min_size: float = 2, scale_size: float = 10) -> np.array: createSizeFromFunc(gr: igraph.Graph, func: str = "betweenness", min_size: float = 2, scale_size: float = 10) -> np.array:
""" """
...@@ -27,7 +28,7 @@ def \ ...@@ -27,7 +28,7 @@ def \
return sizes return sizes
def createFigGraph(gr: igraph.Graph, title: str, hover_field:str = "label", sizes: object = 2, typ_field: str = None, pos: list = None) -> go.Figure: def createFigGraph(gr: igraph.Graph, title: str = "", hover_field:str = "label", sizes: object = 2, typ_field: str = None, pos: list = None) -> go.Figure:
""" """
create figure for plotly create figure for plotly
...@@ -44,7 +45,9 @@ def createFigGraph(gr: igraph.Graph, title: str, hover_field:str = "label", size ...@@ -44,7 +45,9 @@ def createFigGraph(gr: igraph.Graph, title: str, hover_field:str = "label", size
typs = set(gr.vs[typ_field]) typs = set(gr.vs[typ_field])
Zn =gr.vs[typ_field] Zn =gr.vs[typ_field]
if not pos: if not pos:
logging.debug("create positions")
pos = gr.layout_fruchterman_reingold() pos = gr.layout_fruchterman_reingold()
Xn = [k[0] for k in pos.coords] # x-coordinates of nodes Xn = [k[0] for k in pos.coords] # x-coordinates of nodes
Yn = [k[1] for k in pos.coords] # x-coordinates of nodes Yn = [k[1] for k in pos.coords] # x-coordinates of nodes
...@@ -54,6 +57,7 @@ def createFigGraph(gr: igraph.Graph, title: str, hover_field:str = "label", size ...@@ -54,6 +57,7 @@ def createFigGraph(gr: igraph.Graph, title: str, hover_field:str = "label", size
Xe = [] Xe = []
Ye = [] Ye = []
Ze = [] Ze = []
logging.debug("create edges")
for e in gr.es: for e in gr.es:
Xe += [pos.coords[e.source][0], pos.coords[e.target][0], None] # x-coordinates of edge ends Xe += [pos.coords[e.source][0], pos.coords[e.target][0], None] # x-coordinates of edge ends
Ye += [pos.coords[e.source][1], pos.coords[e.target][1], None] Ye += [pos.coords[e.source][1], pos.coords[e.target][1], None]
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment