LoginSignup
4
4

More than 5 years have passed since last update.

igraphにcsvでグラフ構造突っ込んで可視化した

Last updated at Posted at 2013-01-30

csvの構造は、gephiでランダムグラフを作ってcsvでエクスポートしたw
全部フィールドが反映されているのかわからないけど、一応、表示も確認できた。

参考
http://eu-mour.cocolog-nifty.com/euphoria_mourningblog/2010/09/r-1756.html

library("igraph")
g <- read.graph("tableE.csv","csv") //この入れ方はgml拡張子でないと入らない。

以下にエラー match.arg(arg = arg, choices = choices, several.ok = several.ok) :
'arg' should be one of “edgelist”, “pajek”, “ncol”, “lgl”, “graphml”, “dimacs”, “graphdb”, “gml”, “dl”

csvdata<-read.csv("tableE.csv", head = T) //これは見出しがありバージョン
graphdata<-graph.data.frame(csvdata)

graphdata<-graph.data.frame(csvdata[1:50,]) //ノード数かな… ちがった、この場合エッジ数だった。
tkplot(graphdata, vertex.label=V(graphdata)$name)

Loading required package: tcltk

Tcl/Tkインターフェースのロード中 終了済
[1] 1
Error in vids[[1]] : 添え字が許される範囲外です


csvファイルの中身の例(ヘッダごと入れる)

Source,Target,Type,Id,Label,Weight
4992,5009,Directed,6683,,1.0
4992,5012,Directed,6684,,1.0
4992,5021,Directed,6685,,1.0
4992,5023,Directed,6686,,1.0
4992,5029,Directed,6687,,1.0
4993,5002,Directed,6688,,1.0
4993,5024,Directed,6689,,1.0
4993,5030,Directed,6690,,1.0
4993,5039,Directed,6691,,1.0
4994,5003,Directed,6692,,1.0


画像↓ あ、出ないw
ランダムグラフ

4
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
4