Skip to content
Sample android network graph with nodes and edges
Branch: master
Clone or download
Latest commit 5cece64 Dec 21, 2016
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
app jcenter Dec 20, 2016
network-graph jcenter Dec 20, 2016
.gitignore wip Dec 16, 2016
LICENSE.md
README.md readme Dec 16, 2016
android-network-graph-0.0.1.pom jcenter Dec 20, 2016
build.gradle wip Dec 16, 2016
gradle.properties clean Dec 14, 2016
maven-metadata.xml jcenter Dec 20, 2016
settings.gradle clean Dec 16, 2016

README.md

android-network-graph

Description

Network graph based on :

Download

Here's a screenshot :

screen

## Usage

repositories {
    jcenter()
}
dependencies {
    compile 'org.giwi:android-network-graph:0.0.1'
}
  <giwi.org.networkgraph.GraphSurfaceView
      android:id="@+id/mysurface"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:layout_centerHorizontal="true"
      android:layout_centerVertical="true"
      app:nodeBgColor="@android:color/white"
      app:defaultColor="@android:color/black"
      app:edgeColor="@android:color/holo_blue_light"
      app:nodeColor="@android:color/holo_blue_light"
      android:layout_margin="10dp"/>
Node v1 = new SimpleNode("18");
Node v2 = new SimpleNode("24");
graph.getVertex().add(new Vertex(v1, ContextCompat.getDrawable(this, R.drawable.avatar)));
graph.getVertex().add(new Vertex(v2, ContextCompat.getDrawable(this, R.drawable.avatar)));
graph.addEdge(new SimpleEdge(v1, v2, "12"));

Node v3 = new SimpleNode("7");
graph.getVertex().add(new Vertex(v3, ContextCompat.getDrawable(this, R.drawable.avatar)));
graph.addEdge(new SimpleEdge(v2, v3, "23"));

v1 = new SimpleNode("14");
graph.getVertex().add(new Vertex(v1, ContextCompat.getDrawable(this, R.drawable.avatar)));
graph.addEdge(new SimpleEdge(v3, v1, "34"));

v1 = new SimpleNode("10");
graph.getVertex().add(new Vertex(v1, ContextCompat.getDrawable(this, R.drawable.avatar)));
graph.addEdge(new SimpleEdge(v3, v1, "35"));

v1 = new SimpleNode("11");
graph.getVertex().add(new Vertex(v1, ContextCompat.getDrawable(this, R.drawable.avatar)));
graph.addEdge(new SimpleEdge(v1, v3, "36"));
graph.addEdge(new SimpleEdge(v3, v1, "6"));

GraphSurfaceView surface = (GraphSurfaceView) findViewById(R.id.mysurface);
surface.init(graph);

Setting colors programmatically

graph.setDefaultColor(ContextCompat.getColor(this, android.R.color.black));
graph.setEdgeColor(ContextCompat.getColor(this, android.R.color.holo_blue_light));
graph.setNodeColor(ContextCompat.getColor(this, android.R.color.holo_blue_light));
graph.setNodeBgColor(ContextCompat.getColor(this, android.R.color.white));
You can’t perform that action at this time.