示例#1
0
    def _from_struct(self, graphref, bin_str):
        """Reconstructs a Node object from a struct of binary data

        Parameters
        ----------
        graphref: a reference to a vgraph Graph object
        bin_str: a string of binary data

        Returns
        -------
        A vgraph Node object"""
        node_tuple = structs.unpack_node(bin_str)
        n = Node(graphref)
        n.id = node_tuple[0]
        n.label = re.sub(r'\x00', '', node_tuple[1])
        n._set_first_edge_offset(node_tuple[2])
        n._set_last_edge_offset(node_tuple[3])
        return n
示例#2
0
    def _from_struct(self, graphref, bin_str):
        """Reconstructs a Node object from a struct of binary data

        Parameters
        ----------
        graphref: a reference to a vgraph Graph object
        bin_str: a string of binary data

        Returns
        -------
        A vgraph Node object"""
        node_tuple = structs.unpack_node(bin_str)
        n = Node(graphref)
        n.id = node_tuple[0]
        n.label = re.sub(r'\x00', '', node_tuple[1])
        n._set_first_edge_offset(node_tuple[2])
        n._set_last_edge_offset(node_tuple[3])
        return n
示例#3
0
    def get_last_edge_offset(self):
        """Returns the offset into the database file where this
        nodes *last* edge can be found.

        IMPORTANT: You should always read the offset using this getter
        rather than using the objects __dict__ or going around the name
        mangling.  The value is updated on each read in case the node's
        underlying data has been changed since object instantiation.

        Parameters
        ----------
        None

        Returns
        -------
        Integer"""
        st = structs.unpack_node(self.__graph._node_map.read(self.id))
        self.__last_edge = st[3]
        return self.__last_edge
示例#4
0
    def get_last_edge_offset(self):
        """Returns the offset into the database file where this
        nodes *last* edge can be found.

        IMPORTANT: You should always read the offset using this getter
        rather than using the objects __dict__ or going around the name
        mangling.  The value is updated on each read in case the node's
        underlying data has been changed since object instantiation.

        Parameters
        ----------
        None

        Returns
        -------
        Integer"""
        st = structs.unpack_node(self.__graph._node_map.read(self.id))
        self.__last_edge = st[3]
        return self.__last_edge