sf.apps.sample.to_subgraphs¶
-
to_subgraphs
(samples, graph)[source]¶ Converts samples to their subgraph representation.
Input samples are a list of counts that are processed into subgraphs by selecting the nodes where a click occurred.
Example usage:
>>> g = nx.erdos_renyi_graph(5, 0.7) >>> s = [[1, 1, 1, 1, 1], [1, 1, 0, 1, 1], [0, 0, 0, 0, 0], [1, 0, 0, 0, 1]] >>> to_subgraphs(s, g) [[0, 1, 2, 3, 4], [0, 1, 3, 4], [], [0, 4]]
- Parameters
samples (list[list[int]]) – a list of samples, each sample being a list of counts
graph (nx.Graph) – the input graph
- Returns
a list of subgraphs, where each subgraph is represented by a list of its nodes
- Return type
list[list[int]]
code/api/strawberryfields.apps.sample.to_subgraphs
Download Python script
Download Notebook
View on GitHub