Modifying the Universe
The universe is mutable. You have the power to change it! Let’s create a new node using the Atlas Shell.
var bob = Graph.U.createNode(); bob.attr().put(XCSG.name, "bob"); bob.tags().add("Person"); show(universe.nodesTaggedWithAny("Person"));
You've now changed the original index created by Atlas. To keep the universe somewhat sane, Atlas keeps track of what was originally in the universe and what was not. Atlas does this by providing two sets
Common.codemap(), where codemap is the universe before changes were made.
The following query will show an empty graph, even though "bob" exists in the universe.
Since "bob" exists in the universe and not in the index, we should query for the new node using the universe.
This is important to remember when using convenience methods provided by Atlas such as
Common.edges(). The convenience wrappers will use
Let’s create one more node and add an edge between the two nodes.
var bill = Graph.U.createNode(); bill.attr().put(XCSG.name, "bill"); bill.tags().add("Person");
var friends = Graph.U.createEdge(bill, bob); friends.attr().put(XCSG.name, "Friends"); friends.tags().add("Friends");
Important: Changes to the Atlas index are only made to the index in memory. If you have saved a copy of the index before the changes were made those changes will not be present in the serialized index. You will need to re-saved you modified indexes if you wish to save the modifications. You should also be careful to avoid concurrent writes to the Atlas index. Concurrent writing is not supported at this time.
Warning: This is an advanced usage of the Atlas index and the decision to do so should not be taken lightly. Typically you won't need to modify the index, but some analysis tasks may become easier with this ability. Example uses might be to add a new custom tag to
GraphElements in the universe as a way to saving the result of some first pass analysis. Another use might be to add missing program elements that exist outside the Atlas index, such as XML resources for domain specific applications like Android. A word of caution however, changing the index may violate assumptions in the Atlas Schema. Think through the ramifications of your modifications to the index before you make them.