{"id":15030534,"url":"https://github.com/oss-bandb/graphview","last_synced_at":"2026-01-11T22:04:12.883Z","repository":{"id":50409105,"uuid":"122357207","full_name":"oss-bandb/GraphView","owner":"oss-bandb","description":"Android GraphView is used to display data in graph structures.","archived":false,"fork":false,"pushed_at":"2021-04-10T12:34:56.000Z","size":2092,"stargazers_count":1041,"open_issues_count":14,"forks_count":133,"subscribers_count":28,"default_branch":"master","last_synced_at":"2025-04-09T18:09:58.878Z","etag":null,"topics":["android","android-treeview","graph","graph-structure","graphview","tree-structure","treeview","view"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/oss-bandb.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-02-21T15:53:31.000Z","updated_at":"2025-03-25T06:31:26.000Z","dependencies_parsed_at":"2022-08-20T10:00:27.565Z","dependency_job_id":null,"html_url":"https://github.com/oss-bandb/GraphView","commit_stats":null,"previous_names":["team-blox/graphview"],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oss-bandb%2FGraphView","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oss-bandb%2FGraphView/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oss-bandb%2FGraphView/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oss-bandb%2FGraphView/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/oss-bandb","download_url":"https://codeload.github.com/oss-bandb/GraphView/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248633259,"owners_count":21136842,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","android-treeview","graph","graph-structure","graphview","tree-structure","treeview","view"],"created_at":"2024-09-24T20:13:37.650Z","updated_at":"2026-01-11T22:04:12.867Z","avatar_url":"https://github.com/oss-bandb.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"GraphView\n===========\n\nAndroid GraphView is used to display data in graph structures.\n\n![alt Logo](image/GraphView_logo.jpg \"Graph Logo\")\n\nOverview\n========\nThe library can be used within `RecyclerView` and currently works with small graphs only.\n\n**This project is currently experimental and the API subject to breaking changes without notice.**\n\nDownload\n========\nThe library is only available on MavenCentral. Please add this code to your build.gradle file on project level:\n```gradle\nallprojects {\n  repositories {\n    ...\n    mavenCentral()\n  }\n}\n```\n\nAnd add the dependency to the build.gradle file within the app module:\n```gradle\ndependencies {\n    implementation 'dev.bandb.graphview:graphview:0.8.1'\n}\n```\nLayouts\n======\n### Tree\nUses Walker's algorithm with Buchheim's runtime improvements (`BuchheimWalkerLayoutManager` class). Currently only the `TreeEdgeDecoration` can be used to draw the edges. Supports different orientations. All you have to do is using the `BuchheimWalkerConfiguration.Builder.setOrientation(int)` with either `ORIENTATION_LEFT_RIGHT`, `ORIENTATION_RIGHT_LEFT`, `ORIENTATION_TOP_BOTTOM` and\n`ORIENTATION_BOTTOM_TOP` (default). Furthermore parameters like sibling-, level-, subtree separation can be set.\n### Directed graph\nDirected graph drawing by simulating attraction/repulsion forces. For this the algorithm by Fruchterman and Reingold (`FruchtermanReingoldLayoutManager` class) was implemented. To draw the edges you can use `ArrowEdgeDecoration` or `StraightEdgeDecoration`.\n### Layered graph\nAlgorithm from Sugiyama et al. for drawing multilayer graphs, taking advantage of the hierarchical structure of the graph (`SugiyamaLayoutManager` class). Currently only the `SugiyamaArrowEdgeDecoration` can be used to draw the edges. You can also set the parameters for node and level separation using the `SugiyamaConfiguration.Builder`.\n\nUsage\n======\nGraphView must be integrated with `RecyclerView`.\nFor this you’ll need to add a `RecyclerView` to your layout and create an item layout like usually when working with `RecyclerView`.\n\n```xml\n\u003ccom.otaliastudios.zoom.ZoomLayout\n    android:layout_width=\"match_parent\"\n    android:layout_height=\"match_parent\"\n    app:hasClickableChildren=\"true\"\u003e\n\n    \u003candroidx.recyclerview.widget.RecyclerView\n        android:id=\"@+id/recycler\"\n        android:layout_width=\"wrap_content\"\n        android:layout_height=\"wrap_content\" /\u003e\n\n\u003c/com.otaliastudios.zoom.ZoomLayout\u003e\n```\n\nCurrently GraphView must be used together with a Zoom Engine like [ZoomLayout](https://github.com/natario1/ZoomLayout). To change the zoom values just use the different attributes described in the ZoomLayout project site.\n\nTo create a graph, we need to instantiate the `Graph` class. Next submit your graph to your Adapter, for that you must extend from the `AbstractGraphAdapter` class.\n\n```kotlin\nprivate void setupGraphView {\n    val recycler = findViewById(R.id.recycler)\n\n    // 1. Set a layout manager of the ones described above that the RecyclerView will use.\n    val configuration = BuchheimWalkerConfiguration.Builder()\n                    .setSiblingSeparation(100)\n                    .setLevelSeparation(100)\n                    .setSubtreeSeparation(100)\n                    .setOrientation(BuchheimWalkerConfiguration.ORIENTATION_TOP_BOTTOM)\n                    .build()\n    recycler.layoutManager = BuchheimWalkerLayoutManager(context, configuration)\n\n    // 2. Attach item decorations to draw edges\n    recycler.addItemDecoration(TreeEdgeDecoration())\n\n    // 3. Build your graph\n    val graph = Graph()\n    val node1 = Node(\"Parent\")\n    val node2 = Node(\"Child 1\")\n    val node3 = Node(\"Child 2\")\n\n    graph.addEdge(node1, node2)\n    graph.addEdge(node1, node3)\n\n    // 4. You will need a simple Adapter/ViewHolder.\n    // 4.1 Your Adapter class should extend from `AbstractGraphAdapter`\n    adapter = object : AbstractGraphAdapter\u003cNodeViewHolder\u003e() {\n\n        // 4.2 ViewHolder should extend from `RecyclerView.ViewHolder`\n        override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): NodeViewHolder {\n            val view = LayoutInflater.from(parent.context)\n                    .inflate(R.layout.node, parent, false)\n            return NodeViewHolder(view)\n        }\n\n        override fun onBindViewHolder(holder: NodeViewHolder, position: Int) {\n            holder.textView.text = getNodeData(position).toString()\n        }\n    }.apply {\n        // 4.3 Submit the graph\n        this.submitGraph(graph)\n        recycler.adapter = this\n    }\n}\n```\n\nCustomization\n======\nYou can change the edge design by supplying your custom paint object to your edge decorator.\n```kotlin\n    val edgeStyle = Paint(Paint.ANTI_ALIAS_FLAG).apply {\n        strokeWidth = 5f\n        color = Color.BLACK\n        style = Paint.Style.STROKE\n        strokeJoin = Paint.Join.ROUND\n        pathEffect = CornerPathEffect(10f) \n    }\n    \n    recyclerView.addItemDecoration(TreeEdgeDecoration(edgeStyle))\n```\n\nIf you want that your nodes are all the same size you can set `useMaxSize` to `true`. The biggest node defines the size for all the other nodes.\n```kotlin\n    recyclerView.layoutManager = BuchheimWalkerLayoutManager(this, configuration).apply { \n        useMaxSize = true\n    }\n```\n\nExamples\n========\n#### Rooted Tree\n![alt Example](image/Tree.png \"Tree Example\")\n\n#### Directed Graph\n![alt Example](image/Graph.png \"Graph Example\")\n\n#### Layered Graph\n![alt Example](image/LayeredGraph.png \"Layered Graph Example\")\n\nLicense\n=======\n\n    Copyright 2019 - 2021 Block \u0026 Block\n\n    Licensed under the Apache License, Version 2.0 (the \"License\");\n    you may not use this file except in compliance with the License.\n    You may obtain a copy of the License at\n\n       http://www.apache.org/licenses/LICENSE-2.0\n\n    Unless required by applicable law or agreed to in writing, software\n    distributed under the License is distributed on an \"AS IS\" BASIS,\n    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n    See the License for the specific language governing permissions and\n    limitations under the License.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foss-bandb%2Fgraphview","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foss-bandb%2Fgraphview","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foss-bandb%2Fgraphview/lists"}