fixed #1 (mixed up arrow-directions) by removing the usage of networkx and pandas
This commit is contained in:
parent
67e7bcc6fb
commit
66c7c9b963
5 changed files with 10 additions and 34 deletions
|
@ -8,8 +8,6 @@ Create a graph from the links on a website and the following sites.
|
||||||
|
|
||||||
### Pip Dependencies
|
### Pip Dependencies
|
||||||
|
|
||||||
- networkx
|
|
||||||
- pandas
|
|
||||||
- pyvis
|
- pyvis
|
||||||
|
|
||||||
You can install those dependencies with
|
You can install those dependencies with
|
||||||
|
|
13
lib/graph.py
13
lib/graph.py
|
@ -1,13 +1,16 @@
|
||||||
|
|
||||||
from networkx import from_pandas_edgelist
|
|
||||||
from pandas import DataFrame
|
|
||||||
from pyvis.network import Network
|
from pyvis.network import Network
|
||||||
|
|
||||||
def pyvis_graph_from_pandas_DF(pandas_df:DataFrame, source_column:str="link1", target_column:str="link2", heading:str=None) -> Network:
|
from .linkmap import LinkMap
|
||||||
|
|
||||||
|
|
||||||
|
def pyvis_graph_from_linkmap(linkmap:LinkMap, heading:str=None) -> Network:
|
||||||
|
|
||||||
nx = from_pandas_edgelist(pandas_df, source=source_column, target=target_column)
|
|
||||||
pyvis_net = Network(bgcolor="#222222", font_color="#fafafa", width="100%", height="95%", directed=True)
|
pyvis_net = Network(bgcolor="#222222", font_color="#fafafa", width="100%", height="95%", directed=True)
|
||||||
pyvis_net.from_nx(nx, default_node_size=8)
|
|
||||||
|
pyvis_net.add_nodes(linkmap.links, size=[8]*len(linkmap.links))
|
||||||
|
pyvis_net.add_edges(linkmap.link_connections)
|
||||||
|
|
||||||
if heading != None:
|
if heading != None:
|
||||||
pyvis_net.heading = heading + """
|
pyvis_net.heading = heading + """
|
||||||
|
|
|
@ -1,21 +0,0 @@
|
||||||
|
|
||||||
|
|
||||||
from pandas import DataFrame
|
|
||||||
from .linkmap import LinkMap
|
|
||||||
|
|
||||||
|
|
||||||
def linkmap2pandasDF(linkmap:LinkMap) -> DataFrame:
|
|
||||||
|
|
||||||
data_connections = {
|
|
||||||
"link1": [],
|
|
||||||
"link2": []
|
|
||||||
}
|
|
||||||
|
|
||||||
for c in linkmap.link_connections:
|
|
||||||
link1, link2 = c
|
|
||||||
data_connections["link1"].append(link1)
|
|
||||||
data_connections["link2"].append(link2)
|
|
||||||
|
|
||||||
df = DataFrame(data=data_connections)
|
|
||||||
|
|
||||||
return df
|
|
|
@ -1,9 +1,8 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
from lib.args import argparser
|
from lib.args import argparser
|
||||||
from lib.graph import pyvis_graph_from_pandas_DF
|
from lib.graph import pyvis_graph_from_linkmap
|
||||||
from lib.linkmap_from_sitelinks import LinkMapFromSitelinksGenerator
|
from lib.linkmap_from_sitelinks import LinkMapFromSitelinksGenerator
|
||||||
from lib.linkmap2pandasdf import linkmap2pandasDF
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
||||||
|
@ -27,6 +26,5 @@ if __name__ == "__main__":
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
|
||||||
pandasDF = linkmap2pandasDF(nm.get_linkmap())
|
pyvis_network_graph = pyvis_graph_from_linkmap(nm.get_linkmap(), heading=starturl)
|
||||||
pyvis_network_graph = pyvis_graph_from_pandas_DF(pandasDF, heading=starturl)
|
|
||||||
pyvis_network_graph.show("output.html")
|
pyvis_network_graph.show("output.html")
|
||||||
|
|
|
@ -1,3 +1 @@
|
||||||
networkx
|
|
||||||
pandas
|
|
||||||
pyvis
|
pyvis
|
Reference in a new issue