How to use the pyvis.network.Network function in pyvis

To help you get started, we’ve selected a few pyvis examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github libp2p / py-libp2p / tests / pubsub / test_random_topology.py View on Github external
async def test_simple_random():
    num_nodes = 100
    density = 0.1
    num_topics = 20
    max_nodes_per_topic = 69
    max_msgs_per_topic = 1
    topology_test_obj = generate_random_topology(num_nodes, density, num_topics,\
        max_nodes_per_topic, max_msgs_per_topic)
    print(topology_test_obj)
    await perform_test_from_obj(topology_test_obj, timeout_len=20)

    # Save graph
    save_graph = True
    if save_graph:
        net = Network()
        net.barnes_hut()

        adj_list = topology_test_obj["adj_list"]
        # print(list(adj_list.keys()))
        nodes_to_add = list(adj_list.keys())
        net.add_nodes(nodes_to_add)
        print(nodes_to_add)
        print(net.nodes)
        for node in adj_list:
            neighbors = adj_list[node]
            for neighbor in neighbors:
                net.add_edge(node, neighbor)
    
        net.show("random_topology.html")
github eschultze / phishstats-api-network / phishapinetwork.py View on Github external
print ("Query took " + str(r.elapsed.total_seconds()) + " seconds")

url_counter = 0
for url in output:
	url_counter += 1

#Cheking for data
if url_counter <= 0:
	print("Not enough data to create network")
	exit(1)

from pyvis.network import Network

#Parameters for pyvis network
g = Network(height="700px", width="700px", bgcolor="#718487", font_color="white")

#Uncomment below to force a specific algorithm
#g.barnes_hut()
#g.force_atlas_2based()

#Comment below if you don't want physics options on the final html
g.show_buttons(filter_=['physics'])

url_number = 1

for entry in output:

	new_url = entry['url']
	new_url = '{}'.format(new_url)
	new_url_http_code = entry['http_code']
	new_url_http_server = entry['http_server']
github Srinivas11789 / PcapXray / Source / Module / plot_lan_network.py View on Github external
def draw_graph(self, option="All", to_ip="All", from_ip="All"):
        #f = Digraph('network_diagram - '+option, filename=self.filename, engine="dot", format="png")
        #f.attr(rankdir='LR', size='8,5')
        if len(memory.lan_hosts) > 40:
            f = Digraph('network_diagram - '+option, filename=self.filename, engine="sfdp", format="png")
        elif len(memory.lan_hosts) > 20:
            f = Digraph('network_diagram - '+option, filename=self.filename, engine="circo", format="png")
        else:
            f = Digraph('network_diagram - '+option, filename=self.filename, engine="dot", format="png")
        
        interactive_graph = Network(directed=True, height="750px", width="100%", bgcolor="#222222", font_color="white")
        interactive_graph.barnes_hut()
        vis_nodes = []
        vis_edges = []

        f.attr('node', shape='doublecircle')
        #f.node('defaultGateway')

        f.attr('node', shape='circle')

        print("Starting Graph Plotting")
        edge_present = False

        mal, tor, http, https, icmp, dns, clear_text, unknown, covert = 0, 0, 0, 0, 0, 0, 0, 0, 0

        if option == "All":
            # add nodes

pyvis

A Python network graph visualization library

BSD-3-Clause
Latest version published 2 years ago

Package Health Score

61 / 100
Full package analysis

Popular pyvis functions