Gephi Visualization (i)--creating Gephi apps with Gephi toolkit

Source: Internet
Author: User
Tags netbeans

On the prefuse and crawled for some time, found its amiable, easy to get started. But often in open Gephi, import data again run, always still in the heart secretly praise Gephi Gorgeous extreme, no and rival, of course, Gephi also have their own shortcomings, but Gephi is a development, progress, growing open source software. Even if she ever hurt me, I am still reluctant to it, well, I have been very sick ...

To the next, Gephi is an open source free cross-platform JVM-based complex network analysis software designed for interactive visualization and exploration of open source tools for a variety of networks and complex systems, dynamic and hierarchical diagrams. Available as: Exploratory data analysis, link analysis, social network analysis, bio-network analysis, etc. Because Gephi is open source software, it can get its source code, allowing developers to extend and reuse it.

Gephi Development Platform : NetBeans platform (because you didn't understand it before, and wasted a lot of time in the Eclipse environment)

Development language : Java

visualization engine : OpenGL

Gephi official website: http://gephi.github.io/

Gephi's video description: http://v.youku.com/v_show/id_XMjU5MDUwMjg4.html

Gephi API Help documentation:https://gephi.org/docs/api/

Gephi Toolkit: http://gephi.github.io/toolkit/

Gephi Forum: https://forum.gephi.org/

Paste the two pictures gephi do:

  Now, we go deep into the gephi, a good understanding of this strong visual tool, this time we do not go to source code, as an experienced, I would like to remind, if the Java Foundation is not very solid or not too familiar with the NetBeans development platform and swing programming knowledge can go curve, Close to Gephi, otherwise it will make their own head, the more deep, can not extricate themselves ^_^. Here's an example of how to visualize a new Gephi instance if you create it:

  (1) Create a project, a workspace, which is a must-do work, is the prerequisite for the following:

Init a Project-and therefore a workspaceprojectcontroller pc = Lookup.getdefault (). Lookup (Projectcontroller.class); Pc.newproject (); Workspace Workspace = Pc.getcurrentworkspace ();

  

  (2) to obtain the various models of the space and the controller, convenient for later use:

Get models and controllers for the new Workspace-will be useful laterattributemodel Attributemodel = Lookup.getdefaul T (). lookup (Attributecontroller.class). Getmodel (); Graphmodel Graphmodel = Lookup.getdefault (). Lookup (Graphcontroller.class). Getmodel (); Previewmodel model = Lookup.getdefault (). Lookup (Previewcontroller.class). Getmodel (); Importcontroller Importcontroller = Lookup.getdefault (). Lookup (Importcontroller.class); Filtercontroller Filtercontroller = Lookup.getdefault (). Lookup (Filtercontroller.class); Rankingcontroller Rankingcontroller = Lookup.getdefault (). Lookup (Rankingcontroller.class);

  

  (3) Import the data, receive it using container, and import the data into the space:

Import file       Container container;try {    File File = new file (GetClass (). GetResource ("/org/gephi/toolkit/demos /resources/polblogs.gml "). Touri ());    container = importcontroller.importfile (file);    Container.getloader (). Setedgedefault (edgedefault.directed);   Force DIRECTED} catch (Exception ex) {    ex.printstacktrace ();    return;} Append imported data to graphapiimportcontroller.process (container, New Defaultprocessor (), workspace);

  

  (4) Verify that the graphics data is successfully imported by printing the information:

See if graph was well importeddirectedgraph graph = graphmodel.getdirectedgraph (); System.out.println ("Nodes:" + graph.getnodecount ()); System.out.println ("Edges:" + graph.getedgecount ());

 

  (5) Filtering the graphics data:

Filter      Degreerangefilter degreefilter = new Degreerangefilter ();d egreefilter.init (graph); Degreefilter.setrange (New Range (Integer.max_value));     Remove nodes with degree < 30Query query = Filtercontroller.createquery (Degreefilter); Graphview view = filtercontroller.filter (query); Graphmodel.setvisibleview (view);    Set The filter result as the visible view

  

  (6) Verify that the filtering operation works by printing information:

See visible graph Statsundirectedgraph graphvisible = graphmodel.getundirectedgraphvisible (); System.out.println ("Nodes:" + graphvisible.getnodecount ()); System.out.println ("Edges:" + graphvisible.getedgecount ());

  

 (7) Execute yifanhulayout layout algorithm:

Run yifanhulayout for passes-the layout all takes the current visible viewyifanhulayout layout = new Yifanhulay Out (null, new Stepdisplacement (1f)); Layout.setgraphmodel (Graphmodel); Layout.resetpropertiesvalues (); Layout.setoptimaldistance (200f); Layout.initalgo (); for (int i = 0; i < && Layout.canalgo (); i++) {    Layout.goalgo ();} Layout.endalgo ();

  

  (8) Assign the node color according to the node degree value:

Rank Color by degreeranking degreeranking = Rankingcontroller.getmodel (). getranking (Ranking.node_element, ranking.degree_ranking); Abstractcolortransformer Colortransformer = (abstractcolortransformer) Rankingcontroller.getmodel (). GetTransformer (Ranking.node_element, Transformer.renderable_color); Colortransformer.setcolors (New Color[]{new COLOR (0xFEF0D9), New Color (0xb30000)}); Rankingcontroller.transform (Degreeranking,colortransformer);

  

  (9) Allocation node size:

Rank size by Centralityattributecolumn Centralitycolumn = Attributemodel.getnodetable (). GetColumn ( graphdistance.betweenness); Ranking centralityranking = Rankingcontroller.getmodel (). getranking (Ranking.node_element, Centralitycolumn.getid () ); Abstractsizetransformer Sizetransformer = (abstractsizetransformer) Rankingcontroller.getmodel (). GetTransformer ( Ranking.node_element, transformer.renderable_size); sizetransformer.setminsize (3); Sizetransformer.setmaxsize (10) ; Rankingcontroller.transform (Centralityranking,sizetransformer);

  

  (10) Preview the effect configuration, and present to the display, add to the JFrame, interface session display:

Previewpreviewcontroller Previewcontroller = Lookup.getdefault (). Lookup (Previewcontroller.class); Model.getproperties (). Putvalue (Previewproperty.show_node_labels, boolean.true); Model.getproperties (). PutValue ( Previewproperty.edge_color, New Edgecolor (Color.gray)); Model.getproperties (). Putvalue (Previewproperty.edge_ THICKNESS, New Float (0.1f)); Model.getproperties (). Putvalue (Previewproperty.node_label_font, Model.getproperties () . Getfontvalue (Previewproperty.node_label_font). Derivefont (8));p Reviewcontroller.refreshpreview (); New processing target, get the pappletprocessingtarget target = (processingtarget) previewcontroller.getrendertarget ( Rendertarget.processing_target); Papplet applet = Target.getapplet (); Applet.init ()//refresh the preview and reset the Zoompreviewcontroller.render ( target); Target.refresh (); Target.resetzoom ();//add the applet to a JFrame and displayjframe frame = new JFrame ("Test Previe        W "); Frame.setlayout (new BorderLayout ()); Frame.setdefaultcloseoperation (JFrame.        Exit_on_close); Frame.add (applet, borderlayout.center); Frame.pack (); frame.setvisible (true);

 

The console printing information is:

# Nodes loaded:1490# Edges loaded:19025nodes:1490edges:19025nodes:397edges:10599

The result of the execution is as follows:

Learn about the Prefuse API and the idea of creating a prefuse application see the "Ramble on Visualization Prefuse (ii)---a minute to learn Prefuse" and look back at Gephi toolkit the idea of creating Gephi applications is also the same, Follow the time will continue Gephi Toolkit tour!

If you feel useful, you are welcome to praise ^_^! You are also welcome to join the visibility group on the bulletin boards.

This article link: "Gephi visualization (a)--using Gephi toolkit to create Gephi apps"

Gephi Visualization (i)--creating Gephi apps with Gephi toolkit

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.