gephi mysql_【转】使用GEPHI做社会化关系图
目前,做社會化網絡分析的,除了一些在學校里看到過的學術派軟件之外,我所接觸過得用途比較廣的,一是PROCESSING(奧萊利的可視化數據就
是以這個軟件作為講課工具的),二就是09年google
code大賽的冠軍GEPHI。實際上兩者對于編程都需要有一定的基礎,所以不是特別適合文科生使用,特別是PROCESSING,基本上需要JAVA的
一定基礎。而GEPHI在推出新的版本之后,個人認為,簡單的XML代碼方式,以及直接連MYSQL的方式,決定了這個軟件的適用人群上,已經戰勝了
PROCESSING。所以再次說明一個道理,一個好的商業化開源軟件,肯定是一個半小時可以掌握的傻瓜化軟件。
OK,首先講解一下GEPHI的最簡單原理,實際上就是定義兩個東西:
第一個是節點(NODES) 實際上就是關系網中各個孤立的個體
第二個就是邊緣(EDGES) 實際上就是關系網中各個個體之間的關系。
在以上兩點的基礎上,可能還有個體在網絡圖中的位置,關系強度等指標,不過都是額外添加的了。
基于以上的兩個點,我們要做一個簡單的關系圖,只要用XML語言定義一下就可以了。(不要看到XML三個字就慫了,看完之后你就會發現真的很簡單,簡單到把以下代碼復制一下,把相關的指標換成你自己的,就可以做了。)
以上關系圖的代碼:(由于worldpress解釋XML 把左邊的
xml version="1.0" encoding="UTF-8"?>
gexf xmlns:viz=”http:///www.gexf.net/1.1draft/viz” version=”1.1″
xmlns=”http://www.gexf.net/1.1draft”>
meta lastmodifieddate=”2010-05-17+11:28″>
creator>Gephi 0.7
description>Sample dataset – Airlines Routes in the United
States
/meta>
graph defaultedgetype=”directed” idtype=”string”
type=”static”>
nodes count=”17″>
node id=”0.0″ label=”xiaohu”/>
node id=”1.0″ label=”gaoxiaochong”/>
node id=”2.0″ label=”yanzige”/>
node id=”3.0″ label=”cc”/>
node id=”4.0″ label=”weijia”/>
node id=”5.0″ label=”ruiruiba”/>
node id=”6.0″ label=”xiaozuantou”/>
node id=”7.0″ label=”VV”/>
node id=”8.0″ label=”zhishuang”/>
node id=”9.0″ label=”xiaolong”/>
node id=”10.0″ label=”sanxiong”/>
node id=”11.0″ label=”zhanqun”/>
node id=”12.0″ label=”kaige”/>
node id=”13.0″ label=”liusha”/>
node id=”14.0″ label=”xiaode”/>
node id=”15.0″ label=”hanying”/>
node id=”16.0″ label=”lady”/>
/nodes>
edges count=”48″>
edge id=”0″ source=”1.0″ target=”0.0″/>
edge id=”1″ source=”2.0″ target=”0.0″ weight=”8.0″/>
edge id=”2″ source=”3.0″ target=”0.0″ weight=”10.0″/>
edge id=”3″ source=”4.0″ target=”2.0″ weight=”6.0″/>
edge id=”4″ source=”5.0″ target=”0.0″/>
edge id=”5″ source=”6.0″ target=”0.0″/>
edge id=”6″ source=”7.0″ target=”0.0″/>
edge id=”7″ source=”8.0″ target=”0.0″/>
edge id=”8″ source=”9.0″ target=”0.0″/>
edge id=”9″ source=”10.0″ target=”0.0″ weight=”8.0″/>
edge id=”10″ source=”11.0″ target=”0.0″ weight=”10.0″/>
edge id=”11″ source=”12.0″ target=”2.0″ weight=”6.0″/>
edge id=”12″ source=”13.0″ target=”0.0″/>
edge id=”13″ source=”14.0″ target=”0.0″/>
edge id=”14″ source=”15.0″ target=”0.0″/>
edge id=”15″ source=”0.0″ target=”1.0″/>
edge id=”16″ source=”2.0″ target=”1.0″ weight=”10.0″/>
edge id=”17″ source=”4.0″ target=”1.0″ weight=”6.0″/>
edge id=”18″ source=”11.0″ target=”1.0″ weight=”8.0″/>
edge id=”19″ source=”14.0″ target=”1.0″ weight=”10.0″/>
edge id=”20″ source=”16.0″ target=”1.0″ weight=”10.0″/>
edge id=”21″ source=”0.0″ target=”2.0″/>
edge id=”22″ source=”1.0″ target=”2.0″ weight=”10.0″/>
edge id=”23″ source=”10.0″ target=”2.0″ weight=”11.0″/>
edge id=”24″ source=”14.0″ target=”2.0″ weight=”9.0″/>
edge id=”25″ source=”0.0″ target=”3.0″/>
edge id=”26″ source=”11.0″ target=”3.0″ weight=”11.0″/>
edge id=”27″ source=”0.0″ target=”11.0″ weight=”9.0″/>
edge id=”28″ source=”1.0″ target=”11.0″ weight=”10.0″/>
edge id=”29″ source=”3.0″ target=”11.0″ weight=”10.0″/>
edge id=”30″ source=”10.0″ target=”11.0″/>
edge id=”31″ source=”14.0″ target=”11.0″ weight=”10.0″/>
edge id=”32″ source=”0.0″ target=”14.0″ weight=”8.0″/>
edge id=”33″ source=”1.0″ target=”14.0″ weight=”10.0″/>
edge id=”34″ source=”2.0″ target=”14.0″ weight=”6.0″/>
edge id=”35″ source=”3.0″ target=”14.0″/>
edge id=”36″ source=”4.0″ target=”14.0″/>
edge id=”37″ source=”5.0″ target=”14.0″/>
edge id=”38″ source=”10.0″ target=”14.0″/>
edge id=”39″ source=”11.0″ target=”14.0″/>
edge id=”40″ source=”0.0″ target=”16.0″ weight=”8.0″/>
edge id=”41″ source=”1.0″ target=”16.0″ weight=”10.0″/>
edge id=”42″ source=”2.0″ target=”16.0″ weight=”6.0″/>
edge id=”43″ source=”3.0″ target=”16.0″/>
edge id=”44″ source=”4.0″ target=”16.0″/>
edge id=”45″ source=”5.0″ target=”16.0″/>
edge id=”46″ source=”10.0″ target=”16.0″/>
edge id=”47″ source=”11.0″ target=”16.0″/>
/edges>
/graph>
/gexf>
以上代碼放在gephi上直接運行,就可以生成一個簡單的關系圖,是不是很簡單?
OK 問題又來了
要是我有幾百萬個數據,總不能一行一行的代碼吧,這個當然,不能支持數據庫的數據可視化工具肯定不是好工具。GEPHI是直接支持的(這伙還支持
POSTGRESQL 不錯啊!)。我們需要做的是,在MYSQL/ORACLE里面構建兩個表,一個是節點的表,需要包括ID LABLE
SOURCE 等字段 實際上跟上段XML的語言的字段一致) 然后就可以直接讀取。
看上去很忽悠的軟件,是不是很簡單?
現在你要做的,就是準備好基礎數據了,至于社會關系網絡的算法如何定義,那是另外一回事了,學習去吧。
總結
以上是生活随笔為你收集整理的gephi mysql_【转】使用GEPHI做社会化关系图的全部內容,希望文章能夠幫你解決所遇到的問題。
 
                            
                        - 上一篇: HTML常用布局方式
- 下一篇: C语言校园导游系统
