1

Перестраиваю код:

import matplotlib.pyplot as plt
import pandas as pd
import networkx as nx

#plt.figure(figsize=(15, 15))
df = pd.read_csv("clubs.csv")
#df = pd.read_csv("joined.csv",chunksize=1000, names = ['TransaktionID','inputs_input_pubkey_base58', 'outputkey', 'value'])
#print(df['A'])
# 1. Create the graph
g = nx.from_pandas_edgelist(df, source='name', target='club')

# 2. Create a layout for our nodes
layout = nx.spring_layout(g,iterations=50)

# 3. Draw the parts we want
nx.draw_networkx_edges(g, layout, edge_color='#AAAAAA')

clubs = [node for node in g.nodes() if node in df.club.unique()]
size = [g.degree(node) * 80 for node in g.nodes() if node in df.club.unique()]
nx.draw_networkx_nodes(g, layout, nodelist=clubs, node_size=size, node_color='lightblue')

people = [node for node in g.nodes() if node in df.name.unique()]
nx.draw_networkx_nodes(g, layout, nodelist=people, node_size=100, node_color='#AAAAAA')

high_degree_people = [node for node in g.nodes() if node in df.name.unique() and g.degree(node) > 1]
nx.draw_networkx_nodes(g, layout, nodelist=high_degree_people, node_size=100, node_color='#fc8d62')

club_dict = dict(zip(clubs, clubs))
nx.draw_networkx_labels(g, layout, labels=club_dict)

# 4. Turn off the axis because I know you don't want it
plt.axis('off')

plt.title("Revolutionary Clubs")

# 5. Tell matplotlib to show it
plt.show()

Собственно БД для постройки графов такова:

+---+--------------+------------------+-------+
|   |     name     |       club       | value |
+---+--------------+------------------+-------+
| 0 | Adams John   | North Caucus     |    11 |
| 1 | Adams John   | Long Room Club   |  2343 |
| 2 | Adams Samuel | North Caucus     | 99992 |
| 3 | Adams Samuel | Long Room Club   |    32 |
| 4 | Adams Samuel | Boston Committee |     2 |
+---+--------------+------------------+-------+

т.е. clubs.csv:

,name,club,value
0,Adams John,North Caucus,11
1,Adams John,Long Room Club,2343
2,Adams Samuel,North Caucus,99992
3,Adams Samuel,Long Room Club,32
4,Adams Samuel,Boston Committee,2

Теперь же перестраиваю БД в такого вида:

tid,inkey,outkey,value
131f68261e28a80c3300b048c4c51f3ca4745653ba7ad6b20cc9188322818f25,1AbHNFdKJeVL8FRZyRZoiTzG9VCmzLrtvm,11jh1FGcJy2oemZQn9kS8Jdwzej2FsvDT,1000000
74c1a6dd6e88f73035143f8fc7420b5c395d28300a70bb35b943f7f2eddc656d,1AbHNFdKJeVL8FRZyRZoiTzG9VCmzLrtvm,1B1g9Q3tEigAeN4iAFtpj8FEVqmHLX7wVM,4729000000

c огромной размерностью.

Можете посоветовать как это лучше сделать? (В закомментированном коде пытался несколькими методами сделать.)

Суть в том что есть имя узла tid и два поля inkey, outkey - если они совпадают по значению с другим tid, то они соединяются и создают угол. Цена конекта это value (четвертый столбец).

3
  • Вы можете уточнить вопрос? Суть вопроса непонятна 4 июл 2018 в 23:02
  • я дико извиняюсь,но построение графа,а не постройка 5 июл 2018 в 2:13
  • Приведите небольшой воспроизводимый набор входных данных, который позволил бы построить небольшой граф и сам результирующий граф, который вы хотите получить из входных данных. Можно выложить CSV файл на файлообменник... 5 июл 2018 в 6:39

0

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge you have read our privacy policy.

Посмотрите другие вопросы с метками или задайте свой вопрос.