{"id":22769788,"url":"https://github.com/bfontaine/graphs.rb","last_synced_at":"2025-04-15T03:15:31.755Z","repository":{"id":2930716,"uuid":"3942084","full_name":"bfontaine/Graphs.rb","owner":"bfontaine","description":"Some Ruby functions to manipulate graph files","archived":false,"fork":false,"pushed_at":"2014-08-24T12:20:17.000Z","size":1145,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-15T03:15:26.379Z","etag":null,"topics":["gdf","graphs","library","ruby"],"latest_commit_sha":null,"homepage":"https://rubygems.org/gems/graphs","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bfontaine.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":"2012-04-05T17:19:01.000Z","updated_at":"2014-08-23T21:06:37.000Z","dependencies_parsed_at":"2022-08-26T23:23:40.338Z","dependency_job_id":null,"html_url":"https://github.com/bfontaine/Graphs.rb","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bfontaine%2FGraphs.rb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bfontaine%2FGraphs.rb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bfontaine%2FGraphs.rb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bfontaine%2FGraphs.rb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bfontaine","download_url":"https://codeload.github.com/bfontaine/Graphs.rb/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248997084,"owners_count":21195799,"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":["gdf","graphs","library","ruby"],"created_at":"2024-12-11T15:15:47.366Z","updated_at":"2025-04-15T03:15:31.737Z","avatar_url":"https://github.com/bfontaine.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Graphs.rb\n\n[![Build Status](https://travis-ci.org/bfontaine/Graphs.rb.svg?branch=master)](https://travis-ci.org/bfontaine/Graphs.rb)\n[![Gem Version](https://img.shields.io/gem/v/graphs.svg)](http://badge.fury.io/rb/graphs)\n[![Coverage Status](https://img.shields.io/coveralls/bfontaine/Graphs.rb.svg)](https://coveralls.io/r/bfontaine/Graphs.rb)\n[![Inline docs](http://inch-ci.org/github/bfontaine/Graphs.rb.png)](http://inch-ci.org/github/bfontaine/Graphs.rb)\n[![Dependency Status](https://img.shields.io/gemnasium/bfontaine/Graphs.rb.svg)](https://gemnasium.com/bfontaine/Graphs.rb)\n\nThis library allows you to perform some basic operations on graphs, with\nimport/export from/to JSON and [GDF][gdf-format] files.\n\nNote: Before the 0.1.5 version, nodes \u0026 edges were represented as hashes, and\nnow they are `Node` \u0026 `Edge` objects, respectively. They behave like hashes to\npreserve the backward compatibility.\n\nSee the [changelog][changelog] for more info.\n\n[changelog]: https://github.com/bfontaine/Graphs.rb/wiki/Gem-versions\n\n## Install\n\nThe best way is to use the `graphs` gem:\n\n    gem install graphs\n\nIf you want to have the latest version, clone this repo, build the gem, and\ninstall it:\n\n    git clone git://github.com/bfontaine/Graphs.rb.git\n    cd Graphs.rb\n    gem build graphs.gemspec\n    gem install ./graphs-*.gem # you may want to use sudo\n\nIf you want to use the high security trust policy, you need to add my public key\nas a trusted certificate (you only need to do this once. Note: the key changed\non August 24, 2014):\n\n    gem cert --add \u003c(curl -Ls https://gist.github.com/bfontaine/5233818/raw/gem-public-key.pem)\n\nThen, install the gem with the high security trust policy:\n\n    gem install graphs -P HighSecurity\n\n\n## Tests\n\nTo perform the tests, clone this repo, run `bundle install`,\nthen `rake` (you need Ruby ≥1.9.x):\n\n    git clone git://github.com/bfontaine/Graphs.rb.git\n    cd Graphs.rb\n    bundle install\n    bundle exec rake\n\n\n## Docs\n\nThe `Graph` class is a simple graph with nodes and edges. It provides three\nread-write attributes: `nodes`, `edges`, and `attr` (attributes of the graph,\nlike author or description). It can be written in a file using `Graph#write`\nmethod.\n\n`Node` and `Edge` are special classes which inherit from `Hash`. A graph object\nprovide two important attributes:\n\n* `nodes`: A `NodeArray` object (`Array`-like)\n* `edges`: An `EdgeArray` object (`Array`-like, too)\n\nFor backward compatibility, you can create nodes and edges both with `Node` and\n`Edge` objects, and `Hash` ones, e.g.:\n\n```ruby\nrequire 'graph'\n\nnodes = [ {:label =\u003e 'foo'}, {:label =\u003e 'bar'} ]\n\ng = Graph.new nodes\n\n\nnodes2 = nodes.map { |n| Graph::Node.new n }\ng2 = Graph.new nodes2\n\ng == g2 # true\n```\n\nYou can perform some operations on graphes using the `|`, `\u0026`, `^`, `+` or `-`\noperators. See the [documentation](http://rubydoc.info/gems/graphs/frames) for\nmore informations.\n\n### Import/Export\n\nThe library currently support JSON and [GDF][gdf-format]\nformats.\n\nYou can read from files using the `::load` methods of each module:\n\n```ruby\nrequire 'graph'\nrequire 'graphs/gdf'\nrequire 'graphs/json'\n\ng1 = GDF::load('myGraph.gdf')\ng2 = JSONGraph::load('myGraph.json')\n```\n\nYou can also export a graph using the `.write` method. It guesses the format\nusing the file extension. If the file extension is unknown, it uses the YAML\nformat.\n\n```ruby\nrequire 'graph'\nrequire 'graphs/gdf'\nrequire 'graphs/json'\n\ng = Graph.new\n\ng.write('myGraph.gdf')\ng.write('myGraph.json')\n```\n\nNote to [Gephi](https://github.com/gephi/gephi) users who want to export in GDF:\nYou can add the `:gephi` option to `g.write(…)` if you have big numbers.\n`Graph#write` method use `BIGINT` type for big numbers, but Gephi does not\nsupport it and parses it as a string field. So using the following:\n\n```ruby\ng.write('new_trips.gdf', {:gephi=\u003etrue})\n```\n\nmake sure that `INT` is used for all `BIGINT` fields.\n\n\n[gdf-format]: http://guess.wikispot.org/The_GUESS_.gdf_format\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbfontaine%2Fgraphs.rb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbfontaine%2Fgraphs.rb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbfontaine%2Fgraphs.rb/lists"}