2015-09-30 101 views
0

我有一個有向圖,其中有一個開始節點和一個結束節點,它們被定義爲沒有節點結束並且沒有節點進入開始。在我的圖中,我想修復圖形頂部的節點開始和底部的中間節點之間的結束。我怎樣才能做到這一點? enter image description hereigraph中的修復節點

> final_data_graph 
      (conversion) (start)  alpha  beta  delta  epsilon  eta  gamma  iota  kappa  lambda   mi  theta 
(conversion) 0.00000000  0 0.00000000 0.00000000 0.000000e+00 0.000000000 0.00000000 0.000000000 0.00000000 0.000000000 0.00000000 0.000000e+00 0.00000000 
(start)  0.00000000  0 0.03771482 0.14413063 8.571551e-05 0.006128659 0.18025972 0.013071615 0.47426392 0.002914327 0.03891484 4.285776e-05 0.10118716 
alpha   0.18078800  0 0.58092440 0.03215991 1.049263e-04 0.017732543 0.03667174 0.002675620 0.06395257 0.005666020 0.03242222 0.000000e+00 0.03840302 
beta   0.09504413  0 0.08766124 0.35022064 8.486083e-05 0.009164969 0.24753904 0.004327902 0.12075696 0.004752206 0.02274270 0.000000e+00 0.04760692 
delta   0.53333333  0 0.00000000 0.00000000 0.000000e+00 0.066666667 0.00000000 0.000000000 0.26666667 0.066666667 0.00000000 0.000000e+00 0.06666667 
epsilon  0.38628763  0 0.13991081 0.04347826 0.000000e+00 0.105351171 0.08193980 0.005574136 0.10200669 0.007246377 0.05128205 0.000000e+00 0.05351171 
eta   0.42928641  0 0.11002583 0.09969325 0.000000e+00 0.023167582 0.19058767 0.002421698 0.07402325 0.008072328 0.01840491 0.000000e+00 0.03535680 
gamma   0.28192371  0 0.14427861 0.05804312 0.000000e+00 0.021558872 0.08291874 0.066334992 0.15754561 0.018242123 0.05306799 0.000000e+00 0.09950249 
iota   0.23902022  0 0.06370199 0.04091585 1.102111e-04 0.009202623 0.03240205 0.001790930 0.53868408 0.004573759 0.02669863 5.510553e-05 0.03160302 
kappa   0.43064985  0 0.06886518 0.03685742 9.699321e-04 0.018428710 0.06498545 0.002909796 0.09602328 0.128031038 0.05431620 0.000000e+00 0.08244423 
lambda   0.34914361  0 0.08695652 0.02561850 5.855658e-04 0.020348412 0.02547211 0.002488655 0.07539160 0.034401991 0.31620553 0.000000e+00 0.04977309 
mi    0.00000000  0 0.25000000 0.00000000 0.000000e+00 0.000000000 0.00000000 0.000000000 0.50000000 0.000000000 0.00000000 2.500000e-01 0.00000000 
theta   0.13940821  0 0.17562196 0.07949360 1.472104e-04 0.025320183 0.07198587 0.004269101 0.13513911 0.019431768 0.20491683 0.000000e+00 0.12939791 
zeta   0.09929633  0 0.15871775 0.07427678 0.000000e+00 0.039874902 0.07974980 0.001563722 0.23612197 0.007036747 0.08444097 0.000000e+00 0.07271306 
        zeta 
(conversion) 0.000000000 
(start)  0.001285733 
alpha  0.008499029 
beta   0.010098439 
delta  0.000000000 
epsilon  0.023411371 
eta   0.008960284 
gamma  0.016583748 
iota   0.011241528 
kappa  0.015518914 
lambda  0.013614405 
mi   0.000000000 
theta  0.014868247 
zeta   0.146207975 

ig <- graph.adjacency(final_data_graph, mode="directed", weighted=TRUE) 

plot(ig,edge.label=round(E(ig)$weight,3),edge.width=.01,edge.arrow.size=.05,layout=layout.reingold.tilford(ig, root=which(V(ig)$name=='(start)')),vertex.color="white") 

回答

3

我假設你想在底部上方的起始節點和終端可繪製圖表。如果是這樣,您可以使用layout.reingold.tilford

library(igraph) 

# example graph 
g <- graph.empty(directed = T) 
g <- g + vertices(c('D','A','E','F','C','B')) 
g <- g + edge('A','B') 
g <- g + edge('A','C') 
g <- g + edge('B','E') 
g <- g + edge('B','D') 
g <- g + edge('C','D') 
g <- g + edge('D','F') 
g <- g + edge('E','F') 

# create the layout specifying the root node (i.e. start) 
ly <- layout.reingold.tilford(g, root=which(V(g)$name=='A'),flip.y=T) 
# let's plot 
plot.igraph(g,layout=ly) 

enter image description here

+0

感謝您完美的迴應。使用你的代碼片段layout.reingold.tilford(g,root = which(V(g)$ name =='A'),flip.y = T)我可以創建我在問題中添加的圖。但是,如果我想提高alpha beta epsilon等箭頭的可視性,我該如何實現它?對此有一點幫助將不勝感激 –

+0

Mmh ......沒有一個例子真的很難......你能否用'dput(your_graph_variable_here)'的結果更新你的帖子,這樣我就可以重現你的情況了? ;-) – digEmAll

+0

我已經爲我使用的圖形添加了鄰接矩陣和代碼的數據 –