mirror of
https://github.com/Brandon-Rozek/website.git
synced 2025-10-09 14:31:13 +00:00
Added medium syndication metadata
This commit is contained in:
parent
79329aae66
commit
387dd491b1
30 changed files with 175 additions and 134 deletions
|
@ -1,10 +1,12 @@
|
|||
---
|
||||
title: "Networkx Random Sample Graph"
|
||||
date: 2022-04-07T19:48:12-04:00
|
||||
date: 2022-04-07 19:48:12-04:00
|
||||
draft: false
|
||||
tags: ["Python"]
|
||||
math: false
|
||||
medium_enabled: true
|
||||
medium_post_id: e5c5330cc9a7
|
||||
tags:
|
||||
- Python
|
||||
title: Networkx Random Sample Graph
|
||||
---
|
||||
|
||||
I've been working on several algorithms in `networkx`. In order to speed up testing, especially on large graphs, I've been randomly sampling portions of the original graph. The best way I've found to do this is through the following python snippet:
|
||||
|
@ -24,4 +26,4 @@ random_nodes = random.sample(list(G.nodes), SAMPLE_SIZE)
|
|||
G_sample = G.subgraph(random_nodes)
|
||||
```
|
||||
|
||||
However, only considering the nodes when sampling makes it highly likely that the subgraph will significantly less edges. This results in a mostly disconnected subgraph and a loss of information. Sampling the edges prevents this issue at the expense of not capturing single nodes not connected to anything else.
|
||||
However, only considering the nodes when sampling makes it highly likely that the subgraph will significantly less edges. This results in a mostly disconnected subgraph and a loss of information. Sampling the edges prevents this issue at the expense of not capturing single nodes not connected to anything else.
|
Loading…
Add table
Add a link
Reference in a new issue