Group Abstract Group Abstract

Message Boards Message Boards

0
|
4.3K Views
|
2 Replies
|
2 Total Likes
View groups...
Share
Share this post:

[?] Read and map data from a file and create a graph?

Posted 5 years ago
POSTED BY: huakai zeng
2 Replies
Posted 5 years ago

Hi Huakai,

data = Import["~/file.txt", "Table"]
edges = Thread[data[[All, 1]] -> data[[All, 2]]]
weights = data[[All, 3]]
g = Graph[edges, EdgeWeight -> weights, VertexLabels -> Automatic]

enter image description here

POSTED BY: Rohit Namjoshi
Posted 5 years ago

Thank you sir! This works great!

POSTED BY: huakai zeng
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard