Пример #1
0
def draw_edges(graph, ax):
    for nodes in multi2single(graph).edges():
        edges = getedges(graph, nodes)
        nedges = len(edges)
        for edge, move in zip(edges, moves(nedges)):
            if not edge[0] == nodes[0]:
                move = -move
            draw_edge(edge, graph.positions, ax, move=move)
Пример #2
0
def draw_edges(graph, ax):
    for nodes in multi2single(graph).edges():
        edges = getedges(graph, nodes)
        nedges = len(edges)
        for edge, move in zip(edges, moves(nedges)):
            if not edge[0] == nodes[0]:
                move = -move
            draw_edge(edge, graph.positions, ax, move=move)
Пример #3
0
def plot_analysis(graph, analysis, show=True):

    nodes_colors = list()
    ic_nodes_labels = [analysis.nodes[i] for i in analysis.ic_nodes]
    for node in graph.nodes():
        if node in ic_nodes_labels:
            nodes_colors.append('lightsalmon')
        else:
            nodes_colors.append('lightgreen')
    plt.figure()
    ax = plt.axes(frameon=False)
    draw_nodes(graph, ax=ax, colors=nodes_colors)

    ic_edges_labels = \
        [analysis.get_edges_data('label')[i]
         for i in analysis.ic_edges]

    fc_edges_labels = \
        [analysis.get_edges_data('label')[i]
         for i in analysis.fc_edges]

    ec_edges_labels = \
        [analysis.get_edges_data('label')[i]
         for i in analysis.ec_edges]

    for nodes in multi2single(graph).edges():
        edges_colors = list()
        edges_copy = list()
        edges_draw = list()
        edges = getedges(graph, nodes)
        for edge in edges:
            if edge[-1]['label'] in ic_edges_labels:
                edges_copy.append(edge)
                edges_colors.append('port')
                edges_draw.append(True)
            elif edge[-1]['label'] in fc_edges_labels:
                i = analysis.fc_edges[fc_edges_labels.index(edge[-1]['label'])]
                col = analysis.Lambda[:, i]
                if sum(col) > 1:
                    edges_copy.append(edge)
                    edges_colors.append('storage')
                elif sum(col) == 1:
                    inode2 = list(graph.nodes())[list(col).index(1)]
                    inode1 = edge[0] if edge[1] == inode2 else edge[1]
                    edges_copy.append((inode1, inode2, edge[-1]))
                    edges_colors.append('dissipative')
                edges_draw.append(True)
            elif edge[-1]['label'] in ec_edges_labels:
                i = analysis.ec_edges[ec_edges_labels.index(edge[-1]['label'])]
                edges_copy.append(edge)
                edges_colors.append('dissipative')
                edges_draw.append(False)
        nedges = len(edges_copy)
        moves_ = moves(nedges)
        for e in range(nedges):
            edge = edges_copy[e]
            move = moves_[e]
            color = edges_colors[e]
            draw = edges_draw[e]
            if not edge[0] == nodes[0]:
                move = -move
            draw_edge(edge,
                      graph.positions,
                      ax,
                      move=move,
                      colors_type=color,
                      draw=draw)
    plt.tight_layout()
    ax.axes.get_xaxis().set_visible(False)
    ax.axes.get_yaxis().set_visible(False)
    if show:
        plt.show()
Пример #4
0
def plot_analysis(graph, analysis, show=True):

    nodes_colors = list()
    ic_nodes_labels = [analysis.nodes[i] for i in analysis.ic_nodes]
    for node in graph.nodes():
        if node in ic_nodes_labels:
            nodes_colors.append('lightsalmon')
        else:
            nodes_colors.append('lightgreen')
    plt.figure()
    ax = plt.axes(frameon=False)
    draw_nodes(graph, ax=ax, colors=nodes_colors)

    ic_edges_labels = \
        [analysis.get_edges_data('label')[i]
         for i in analysis.ic_edges]

    fc_edges_labels = \
        [analysis.get_edges_data('label')[i]
         for i in analysis.fc_edges]

    ec_edges_labels = \
        [analysis.get_edges_data('label')[i]
         for i in analysis.ec_edges]

    for nodes in multi2single(graph).edges():
        edges_colors = list()
        edges_copy = list()
        edges_draw = list()
        edges = getedges(graph, nodes)
        for edge in edges:
            if edge[-1]['label'] in ic_edges_labels:
                edges_copy.append(edge)
                edges_colors.append('port')
                edges_draw.append(True)
            elif edge[-1]['label'] in fc_edges_labels:
                i = analysis.fc_edges[fc_edges_labels.index(
                        edge[-1]['label'])]
                col = analysis.Lambda[:, i]
                if sum(col) > 1:
                    edges_copy.append(edge)
                    edges_colors.append('storage')
                elif sum(col) == 1:
                    inode2 = list(graph.nodes())[list(col).index(1)]
                    inode1 = edge[0] if edge[1] == inode2 else edge[1]
                    edges_copy.append((inode1, inode2, edge[-1]))
                    edges_colors.append('dissipative')
                edges_draw.append(True)
            elif edge[-1]['label'] in ec_edges_labels:
                i = analysis.ec_edges[ec_edges_labels.index(edge[-1]['label'])]
                edges_copy.append(edge)
                edges_colors.append('dissipative')
                edges_draw.append(False)
        nedges = len(edges_copy)
        moves_ = moves(nedges)
        for e in range(nedges):
            edge = edges_copy[e]
            move = moves_[e]
            color = edges_colors[e]
            draw = edges_draw[e]
            if not edge[0] == nodes[0]:
                move = -move
            draw_edge(edge, graph.positions, ax, move=move,
                      colors_type=color, draw=draw)
    plt.tight_layout()
    ax.axes.get_xaxis().set_visible(False)
    ax.axes.get_yaxis().set_visible(False)
    if show:
        plt.show()