simple_graph 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7d18636a755c3abfcbfecd3f6f64c21024126a17
4
- data.tar.gz: c300ccf22026e00271ee1dce43d48e3acaecf004
3
+ metadata.gz: e87715221bb60921ac6e47b6fa6efac9f7234ddd
4
+ data.tar.gz: e5380f1a8856e9e076dcf680919a531eafa43691
5
5
  SHA512:
6
- metadata.gz: 050fc8f52c0ef9dd4b0a5d4a9c7043bbf7428a6ea1763dbf12a9e994a7b4b57d99135e8fdae3daceec24b65bc1b36922c64f22f39c9e7d18fa21791ed764fc4e
7
- data.tar.gz: 63d0d1e856c9a1bf41ccac6d4146c24983ed4cec00fe8356b83d16666abe77153bfa31b559b26825a693020526b8242ab42f6737f0c7a3f426e34fb6c81ab2c5
6
+ metadata.gz: 55977cfed82c9ecdd1f781f2a071b8b68c6c39056a830a2db5eb6110f48673f8506f4f5d8848ee62a3fe5c0de1710be1524f65f94479cfb4fa4d9b3be8f7b668
7
+ data.tar.gz: 80fd775f88ef01d486be721d645a71715c0b5c707a9f29b677782b60acb11c70cad6c596ed4e7767687efe7dcce1847184b098debe59438cebefc75519dc54bb
data/README.md CHANGED
@@ -54,16 +54,24 @@ bar = graph.add_node(id: "Igor", data: stuff)
54
54
  graph.connect_nodes(foo, "Kevin")
55
55
 
56
56
  # Paths between two nodes can be found by breadth-first search
57
- # This method will return a array of arrays containing node IDs describing the path
58
57
  paths = graph.find_paths(foo, bar)
59
58
 
60
59
  # Retrieving info about the graph
60
+ graph.nodes # Lists all of the nodes in the graph
61
61
  graph.node_count # Returns the amount of nodes in the graph
62
62
  graph.node_ids # Array of node identifiers in the graph
63
+ graph.are_connected?(foo, bar) # Checks whether two nodes are connected by an Edge
64
+ graph.include?("Kevin") # Checks whether the graph includes a node with the given ID
63
65
 
64
66
  # Graphs can be written to files in the DOT format to be used with Graphviz
65
67
  # Note that the node ID will be used for labels
66
68
  File.write("test.dot", graph.to_dot_string)
69
+
70
+ # Export a graph to a JSON file
71
+ File.write("output.json", graph.to_json)
72
+
73
+ # Import a graph from a JSON file
74
+ graph.load_from_json(File.read("input.json"))
67
75
  ```
68
76
 
69
77
  ## Contributing