I am trying to draw a visualization for a network using three different lists which form 3 types of nodes
The below code is working. as shown, it takes two lists. userId, ratings.
However, I want my graph to be tri-partite. That is, { 'user':userId, 'review':ratings, 'product':prodId}
G=nx.from_pandas_edgelist(user_review_graph, 'user', 'review','product')
I know that, from_pandas_edgelist only accepts 'from' and 'to'. But, I dont know the alternative to it.
Basically, my graph has edges (user,ratings) and (ratings, products). I get two seperate visualizations i want them in one.
I am new to visualising networks and need some help on this.
import networkx as nx
import matplotlib.pyplot as plt
user_review_graph = pd.DataFrame({ 'user':userId, 'review':ratings})
user_review_graph
G=nx.from_pandas_edgelist(user_review_graph, 'user', 'review')
pos=nx.spring_layout(G)
nx.draw(G,pos,node_color='#A0CBE2',edge_color='#BB0000',width=2,edge_cmap=plt.cm.Blues,with_labels=True, font_weight=500,font_size=7)
#plt.show()
plt.savefig("test2.png", dpi=500, facecolor='w', edgecolor='w',orientation='portrait', papertype=None, format=None,transparent=False, bbox_inches=None, pad_inches=0.1)