Beispiel #1
0
def mintree(G, conn):

    if sufficient(G):
        H = nx.minimum_spanning_tree(G)
        ui.separator()
        st.write("#### Minimum tree")
        viz.draw(H, conn, cmap=cmap)
        st.pyplot()
Beispiel #2
0
def graph_plot(G, conn, center, radius, communities=False):
    full_graph = center is None
    if full_graph: pos = nx.kamada_kawai_layout
    # a = -chem.subgraph_energy(conn,G)
    # b = -chem.total_energy(conn)
    # st.write(f"Net gravity = **{a:2.3f}** - {b:2.3f} = {a-b:2.3f}")
    viz.draw(G, conn, labels=not full_graph, cmap=cmap)
    try:
        leaves, expected_leaves, slope = stats.leaf_analysis(G)
        print(leaves)
        st.write(
            f"Exponent {slope:1.2f} predicts {expected_leaves:1.0f} terminal nodes, {leaves} found"
        )
    except:
        pass
    #viz.draw(G,conn,labels = not full_graph, cmap=cmap)
    try:
        out, coll = chem.gravity_partition(G, conn)
        ui.separator()
        st.write("### Expanding")
        viz.draw(out, conn, cmap=cmap)
        st.write("### Collapsing")
        viz.draw(coll, conn, cmap=cmap)
    except:
        st.write("Couldn't make expanding/collapsing subsets")

    if full_graph:
        ui.separator()
        st.write("### Components")
        S = [G.subgraph(c).copy() for c in nx.connected_components(G)]
        for subgraph in S:
            viz.draw(subgraph, conn, cmap=cmap)
            ui.separator()

    if sufficient(G) and communities:
        u = nx.algorithms.community.kernighan_lin.kernighan_lin_bisection(G)
        thresh = 4 if full_graph else 4
        S = [G.subgraph(c).copy() for c in u if len(c) > thresh]
        st.write("### Communities")
        for subgraph in S:
            viz.draw(subgraph, conn, cmap=cmap)
            ui.separator()
Beispiel #3
0
def view_degrees(G, conn):
    if sufficient(G):
        ui.separator()
        st.write("### Degree distribution")
        plot_degree_distribution(G)
Beispiel #4
0
def view_spectrum(G, conn):
    if sufficient(G):
        ui.separator()
        st.write("### Laplacian spectrum")
        eigenvalues(G)
Beispiel #5
0
def view_energy(G, conn):
    if sufficient(G):
        ui.separator()
        st.write("### Energy density")
        energy(G, conn)
Beispiel #6
0
    #	st.write("## `sursis`")
    col1, col2 = st.columns(2)

    major_mode = col1.radio(label="Major mode",\
                                 options=["Browse","Edit"])
    if major_mode == "Browse":
        op_mode=col2.radio(label="Operation mode",\
         options=[view_mode, spath_mode, stats_mode])
    elif major_mode == "Edit":
        op_mode = col2.radio(label="Operation mode",\
         options=[trail_mode, dyad_mode, triad_mode,merge_mode, edge_mode,
          node_mode,
          ])

    if op_mode == node_mode:
        ui.separator()
        st.write("### Add/remove nodes")
        dlg.node_entry(conn)
    elif op_mode == dyad_mode:
        ui.separator()
        st.write("### Add two nodes and connect them")
        dlg.dyad_entry(conn)
    elif op_mode == triad_mode:
        ui.separator()
        st.write("### Add a parent node and two children")
        dlg.triad_entry(conn)
    elif op_mode == edge_mode:
        ui.separator()
        st.write("### Add/remove connections")
        dlg.edge_entry(conn)
    elif op_mode == cluster_mode: