Invisible Nodes with Gephi Toolkit 0.9.1

Screenshots, Vectorial Preview and printable exports
Post Reply
Posts: 8
Joined: 10 Jun 2016 18:19

Invisible Nodes with Gephi Toolkit 0.9.1

Post by littleBobbyTables » 12 Jun 2016 17:15


I am having an issue where I am trying to create an display a graph manually (i.e. not importing from an external file) but the nodes are not showing up. They seem just entirely invisible. I have tried changing the background color to see if they were just white on a white background, but that does not appear to be the issue. The edges show up just fine, but the nodes just don't seem to appear. My code, shown below, is mostly just pieces of the demo code from the toolkit being put together to get my desired output. Also attached is a screenshot of my display. Any help would be much appreciated. Thank you!

Code: Select all

import java.awt.BorderLayout;
import java.awt.Color;

import javax.swing.JFrame;

import org.gephi.graph.api.DirectedGraph;
import org.gephi.graph.api.Edge;
import org.gephi.graph.api.GraphController;
import org.gephi.graph.api.GraphModel;
import org.gephi.graph.api.Node;
import org.gephi.preview.api.G2DTarget;
import org.gephi.preview.api.PreviewController;
import org.gephi.preview.api.PreviewModel;
import org.gephi.preview.api.PreviewProperty;
import org.gephi.preview.api.RenderTarget;
import org.gephi.preview.types.DependantColor;
import org.gephi.project.api.ProjectController;
import org.gephi.project.api.Workspace;
import org.gephi.toolkit.demos.plugins.preview.PreviewSketch;
import org.openide.util.Lookup;

 * @author JasonB
public class BasicGraphBuild {

	public static void main(String[] args) {
		BasicGraphBuild bscGraphBuild = new BasicGraphBuild();

	public void script() {
		ProjectController pc =
		Workspace workspace = pc.getCurrentWorkspace();

		GraphModel graphModel = Lookup.getDefault()

		Node n0 = graphModel.factory().newNode("n0");
		n0.setLabel("Node 0");
		n0.setX((float) ((0.01 + Math.random()) * 1000) - 500);
		n0.setY((float) ((0.01 + Math.random()) * 1000) - 500);
		Node n1 = graphModel.factory().newNode("n1");
		n1.setLabel("Node 1");
		n1.setX((float) ((0.01 + Math.random()) * 1000) - 500);
		n1.setY((float) ((0.01 + Math.random()) * 1000) - 500);
		Node n2 = graphModel.factory().newNode("n2");
		n2.setLabel("Node 2");
		n2.setX((float) ((0.01 + Math.random()) * 100) - 50);
		n2.setY((float) ((0.01 + Math.random()) * 100) - 50);

		Edge e1 = graphModel.factory().newEdge(n0, n1, 0, 1.0, true);
		Edge e2 = graphModel.factory().newEdge(n0, n2, 0, 1.0, true);

		DirectedGraph directedGraph = graphModel.getDirectedGraph();

		// Preview configuration
		PreviewController previewController =
		PreviewModel previewModel = previewController.getModel();
				new DependantColor(Color.BLACK));
		previewModel.getProperties().putValue(PreviewProperty.EDGE_OPACITY, 50);
		previewModel.getProperties().putValue(PreviewProperty.EDGE_RADIUS, 10f);

		// New Processing target, get the PApplet
		G2DTarget target = (G2DTarget) previewController
		PreviewSketch previewSketch = new PreviewSketch(target);

		// Add the applet to a JFrame and display
		JFrame frame = new JFrame("Test Preview");
		frame.setLayout(new BorderLayout());

		frame.add(previewSketch, BorderLayout.CENTER);

		frame.setSize(1024, 768);


The display from the referenced code.

User avatar
Gephi Code Manager
Posts: 976
Joined: 22 Mar 2010 15:30
Location: Madrid, Spain

Re: Invisible Nodes with Gephi Toolkit 0.9.1

Post by eduramiba » 12 Jun 2016 20:01

Can you try to set node opacity as a float (100f)? Not sure this is the problem but might be.

Posts: 8
Joined: 10 Jun 2016 18:19

Re: Invisible Nodes with Gephi Toolkit 0.9.1

Post by littleBobbyTables » 12 Jun 2016 20:17

Thanks for your suggestion! I just tried that, but no luck. they still don't show up.

Posts: 7
Joined: 08 Jun 2016 19:36

Re: Invisible Nodes with Gephi Toolkit 0.9.1

Post by Node231 » 16 Jun 2016 20:01

Today I had a relatively similar issue, using 0.8.2 though

my workaround was installing an older version of java, other than that I have no idea :(

I used: ... 19409.html

Posts: 8
Joined: 10 Jun 2016 18:19

Re: Invisible Nodes with Gephi Toolkit 0.9.1

Post by littleBobbyTables » 16 Jun 2016 20:08

Sadly, I can't do that. I need Java 8 for the rests of the project. Thanks, though!

Posts: 8
Joined: 10 Jun 2016 18:19

Re: Invisible Nodes with Gephi Toolkit 0.9.1

Post by littleBobbyTables » 11 Jul 2016 15:48

Sorry this has taken so long to update, but I have (sort of) fixed this problem with a rather strange workaround. Instead of building the graph the way I have done above, I instead used an ImportController and ImportContainer and with that used NodeDraftImpl objects and EdgeDraftImpl objects. I don't know why this solves the problem and makes nodes visible, but it worked for me. Most all of the methods that exist to modify the nodes and edges in the other method still exist in some regard with this method. The other thing to keep in mind is that you need to remember to process the container after building the graph in it (that's the point of the ImportController). That's how I solved this. I hope it helps anyone with a similar issue!

Posts: 1
Joined: 23 Nov 2016 15:32

Re: Invisible Nodes with Gephi Toolkit 0.9.1

Post by semen.kosyachenko » 23 Nov 2016 15:36

hi, I have same problem, and I don't know what to do with it.
I can see edges, but not nodes(((
so littleBobbyTables could you post the code how you make graph manualy using ImportController and ImportContainer?

Posts: 1
Joined: 09 Feb 2018 03:45

Re: Invisible Nodes with Gephi Toolkit 0.9.1

Post by khuatthanhson94 » 09 Feb 2018 03:47

Dear sir,
I am a researcher at Department of Technology and Software Solutions - Institute of information technology - VietNam Academy of Science and Technology.
I am having a research paper on information diffusion of Twitter - a social networking and i watched your video for demo of same problem.

Can you tell me about source code which resolve this problem?

Problem: Currently, I am coding on java but i had one problem: I want to show all Edge when i clicked node. Like on Gephi app. Please help me.

Thanks for helpful,

Post Reply