Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

graph_lib

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

graph_lib

  • 0.0.1
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

GraphLib

A very minimal graph organization library in Ruby.

Allows you to add vertices and edges and know about parents and children.

require './graph.rb'

g = Graph.new
g.add_vertex("a")
g.add_vertex("b")
g.add_vertex("c")
g.add_vertex("d")

g.add_edge("a", "b")
g.add_edge("a", "c")
g.add_edge("b", "d")
g.add_edge("c", "d")

g.children_for("a")
g.parents_for("d")

If you try to add an edge between nodes that don't exist, you get an error...

You can also generate a graph directly from a json document like this:

{
  "vertices": ["a", "b", "c", "d"],
  "edges": [
    ["a", "b"],
    ["a", "c"],
    ["b", "d"],
    ["c", "d"]
  ]
}

Do this by either calling Graph.from_hash(graph_hash) or Graph.from_file('graph.json').

FAQs

Package last updated on 25 Jan 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc