Class | JavaClass::Dependencies::GraphmlSerializer |
In: |
lib/javaclass/dependencies/graphml_serializer.rb
|
Parent: | Object |
Serializes a Graph of Node to GraphML (XML). To see the graph, use yED, www.yworks.com/en/products_yed_about.html to
Author: | Peter Kofler |
Create a serializer with options hash:
edges: | how to chart edge labes, either :no_text or :with_counts |
# File lib/javaclass/dependencies/graphml_serializer.rb, line 17 def initialize(options = { :edges => :with_counts }) @options = options end
Add the node as XML to the container .
# File lib/javaclass/dependencies/graphml_serializer.rb, line 57 def add_node_as_xml(container, node) add_node_element(container, node) node.dependencies.keys.each do |dep| add_edge_element(container, node, dep) end end
Return an XML document of the GraphML serialized graph .
# File lib/javaclass/dependencies/graphml_serializer.rb, line 31 def graph_to_xml(graph) doc = create_xml_doc container = add_graph_element(doc) graph.to_a.each { |node| add_node_as_xml(container, node) } doc end