Exemplo n.º 1
0
  def initialize(self):
    """ Init gl.Graph
    """
    node1_path = utils.gen_node_data([self._node1_type], [self._node1_range],
                                     [utils.ATTRIBUTED])[0]
    node2_path = utils.gen_node_data([self._node2_type], [self._node2_range],
                                     [utils.WEIGHTED, utils.LABELED])[0]
    edge1_path = utils.gen_edge_data(self._node1_type, self._node2_type,
                                     self._node1_range, self._node2_range,
                                     schema=[utils.ATTRIBUTED, utils.LABELED])
    edge2_path = utils.gen_edge_data(self._node2_type, self._node1_type,
                                     self._node2_range, self._node1_range,
                                     schema=[utils.ATTRIBUTED, utils.WEIGHTED])
    edge3_path = utils.gen_edge_data(self._node2_type, self._node2_type,
                                     self._node2_range, self._node2_range,
                                     schema=[utils.WEIGHTED])

    self.__class__.needs_initial = False
    self.__class__.g = gl.Graph() \
      .node(source=node1_path, node_type=self._node1_type,
            decoder=self._node1_decoder) \
      .node(source=node2_path, node_type=self._node2_type,
            decoder=self._node2_decoder) \
      .edge(source=edge1_path,
            edge_type=(self._node1_type, self._node2_type, self._edge1_type),
            decoder=self._edge1_decoder, directed=False) \
      .edge(source=edge2_path,
            edge_type=(self._node2_type, self._node1_type, self._edge2_type),
            decoder=self._edge2_decoder) \
      .edge(source=edge3_path,
            edge_type=(self._node2_type, self._node2_type, self._edge3_type),
            decoder=self._edge3_decoder, directed=False)
    self.__class__.g.init(server_id=0, server_count=1,
                          tracker=utils.TRACKER_PATH)
Exemplo n.º 2
0
 def gen_test_data(self, schema):
     paths = utils.gen_node_data(id_type=[self.node_type_],
                                 id_range=self.value_range_,
                                 schema=schema)
     return paths[0]
Exemplo n.º 3
0
 def gen_test_data(self, schema):
     return utils.gen_node_data(id_type=self.node_type_,
                                id_range=self.value_range_,
                                schema=schema)
Exemplo n.º 4
0
    def initialize(self):
        """ Init gl.Graph
    """
        node1_path = utils.gen_node_data(self._node1_type, self._node1_range,
                                         [utils.ATTRIBUTED])
        node2_path = utils.gen_node_data(self._node2_type, self._node2_range,
                                         [utils.WEIGHTED, utils.LABELED])
        edge1_path = utils.gen_edge_data(
            self._node1_type,
            self._node2_type,
            self._node1_range,
            self._node2_range,
            schema=[utils.ATTRIBUTED, utils.LABELED])
        edge2_path = utils.gen_edge_data(
            self._node2_type,
            self._node1_type,
            self._node2_range,
            self._node1_range,
            schema=[utils.ATTRIBUTED, utils.WEIGHTED])
        edge3_path = utils.gen_edge_data(self._node2_type,
                                         self._node2_type,
                                         self._node2_range,
                                         self._node2_range,
                                         schema=[utils.WEIGHTED])

        node3_path = utils.gen_entity_node(
            self._node3_type)  # attr labeled nodes
        edge4_path = utils.gen_relation_edge(
            self._edge4_type)  # weighted edges
        cond_node_path = utils.gen_cond_node(
            self._cond_node_type)  # attr weighted nodes

        # test for mask.
        train_node_path = utils.gen_node_data(self._node1_type,
                                              self._train_node_range,
                                              schema=[utils.WEIGHTED],
                                              mask="train")
        test_node_path = utils.gen_node_data(self._node1_type,
                                             self._test_node_range,
                                             schema=[utils.WEIGHTED],
                                             mask="test")
        val_node_path = utils.gen_node_data(self._node1_type,
                                            self._val_node_range,
                                            schema=[utils.WEIGHTED],
                                            mask="val")
        train_edge_path = utils.gen_edge_data(self._node1_type,
                                              self._node2_type,
                                              self._train_node_range,
                                              self._node2_range,
                                              schema=[],
                                              mask="train")
        test_edge_path = utils.gen_edge_data(self._node1_type,
                                             self._node2_type,
                                             self._test_node_range,
                                             self._node2_range,
                                             schema=[],
                                             mask="test")
        val_edge_path = utils.gen_edge_data(self._node1_type,
                                            self._node2_type,
                                            self._val_node_range,
                                            self._node2_range,
                                            schema=[],
                                            mask="val")

        self.__class__.needs_initial = False
        self.__class__.g = gl.Graph() \
          .node(source=node1_path, node_type=self._node1_type,
                decoder=self._node1_decoder) \
          .node(source=node2_path, node_type=self._node2_type,
                decoder=self._node2_decoder) \
          .node(source=node3_path, node_type=self._node3_type,
                decoder=self._node3_decoder) \
          .node(source=cond_node_path, node_type=self._cond_node_type,
                decoder=self._cond_node_deocder) \
          .node(source=train_node_path, node_type=self._node1_type,
                decoder=gl.Decoder(weighted=True), mask=gl.Mask.TRAIN) \
          .node(source=test_node_path, node_type=self._node1_type,
                decoder=gl.Decoder(weighted=True), mask=gl.Mask.TEST) \
          .node(source=val_node_path, node_type=self._node1_type,
                decoder=gl.Decoder(weighted=True), mask=gl.Mask.VAL) \
          .edge(source=edge1_path,
                edge_type=(self._node1_type, self._node2_type, self._edge1_type),
                decoder=self._edge1_decoder, directed=False) \
          .edge(source=edge2_path,
                edge_type=(self._node2_type, self._node1_type, self._edge2_type),
                decoder=self._edge2_decoder) \
          .edge(source=edge3_path,
                edge_type=(self._node2_type, self._node2_type, self._edge3_type),
                decoder=self._edge3_decoder, directed=False) \
          .edge(source=edge4_path,
                edge_type=(self._node3_type, self._node3_type, self._edge4_type),
                decoder=self._edge4_decoder, directed=False) \
          .edge(source=edge4_path,
                edge_type=(self._cond_node_type, self._cond_node_type, self._cond_edge_type),
                decoder=self._edge4_decoder, directed=True) \
          .edge(source=train_edge_path,
                edge_type=(self._node1_type, self._node2_type, self._edge1_type),
                decoder=gl.Decoder(), mask=gl.Mask.TRAIN) \
          .edge(source=test_edge_path,
                edge_type=(self._node1_type, self._node2_type, self._edge1_type),
                decoder=gl.Decoder(), mask=gl.Mask.TEST) \
          .edge(source=val_edge_path,
                edge_type=(self._node1_type, self._node2_type, self._edge1_type),
                decoder=gl.Decoder(), mask=gl.Mask.VAL)

        self.__class__.g.init(tracker=utils.TRACKER_PATH)