def sample(self, args: argparse.Namespace, prev_state: SampleState = None) -> Tuple['Graph', Sample]: """Sample a set of vertices from the graph. Parameters ---------- args : Namespace the parsed command-line arguments Returns ------ subgraph : Graph the subgraph created from the sampled Graph vertices sample : Sample the sample object containing the vertex and block mappings """ sample_size = int((self.num_nodes * (args.sample_size / 100)) / args.sample_iterations) if prev_state is None: prev_state = SampleState(sample_size) sample_object = Sample.create_sample(self.num_nodes, self.out_neighbors, self.in_neighbors, self.true_block_assignment, args, prev_state) subgraph = Graph(sample_object.out_neighbors, sample_object.in_neighbors, sample_object.sample_num, sample_object.num_edges, sample_object.true_block_assignment) return subgraph, sample_object
def sample(self, graph: Graph, args: argparse.Namespace, prev_state: SampleState = None) -> Tuple[Graph, Sample]: """Sample a set of vertices from the graph. Parameters ---------- full_graph : Graph the graph from which to sample vertices args : Namespace the parsed command-line arguments prev_state : SampleState if prev_state is not None, sample will be conditioned on the previously selected vertices Returns ------ sampled_graph : Graph the sampled graph created from the sampled Graph vertices sample : Sample the sample object containing the vertex and block mappings """ sample_size = int((self.full_graph.num_vertices() * (args.sample_size / 100)) / args.sample_iterations) if prev_state is None: prev_state = SampleState(sample_size) sample_object = Sample.create_sample(self.full_graph, self.true_block_assignment, args, prev_state) return sample_object.graph, sample_object