MCPcopy Create free account
hub / github.com/easy-graph/Easy-Graph / add_viz

Method add_viz

easygraph/readwrite/gexf.py:788–831  ·  view source on GitHub ↗
(self, data, node_xml)

Source from the content-addressed store, hash-verified

786 return data
787
788 def add_viz(self, data, node_xml):
789 # add viz element for node
790 viz = {}
791 color = node_xml.find(f"{{{self.NS_VIZ}}}color")
792 if color is not None:
793 if self.VERSION == "1.1":
794 viz["color"] = {
795 "r": int(color.get("r")),
796 "g": int(color.get("g")),
797 "b": int(color.get("b")),
798 }
799 else:
800 viz["color"] = {
801 "r": int(color.get("r")),
802 "g": int(color.get("g")),
803 "b": int(color.get("b")),
804 "a": float(color.get("a", 1)),
805 }
806
807 size = node_xml.find(f"{{{self.NS_VIZ}}}size")
808 if size is not None:
809 viz["size"] = float(size.get("value"))
810
811 thickness = node_xml.find(f"{{{self.NS_VIZ}}}thickness")
812 if thickness is not None:
813 viz["thickness"] = float(thickness.get("value"))
814
815 shape = node_xml.find(f"{{{self.NS_VIZ}}}shape")
816 if shape is not None:
817 viz["shape"] = shape.get("shape")
818 if viz["shape"] == "image":
819 viz["shape"] = shape.get("uri")
820
821 position = node_xml.find(f"{{{self.NS_VIZ}}}position")
822 if position is not None:
823 viz["position"] = {
824 "x": float(position.get("x", 0)),
825 "y": float(position.get("y", 0)),
826 "z": float(position.get("z", 0)),
827 }
828
829 if len(viz) > 0:
830 data["viz"] = viz
831 return data
832
833 def add_parents(self, data, node_xml):
834 parents_element = node_xml.find(f"{{{self.NS_GEXF}}}parents")

Callers 1

add_nodeMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected