Spaces:
Sleeping
Sleeping
hengjie yang
commited on
Commit
·
9580089
0
Parent(s):
Initial commit: Voice Clone App with Gradio interface
Browse filesThis view is limited to 50 files because it contains too many changes.
See raw diff
- .gitattributes +33 -0
- .gitignore +44 -0
- .venv/bin/Activate.ps1 +241 -0
- .venv/bin/activate +76 -0
- .venv/bin/activate.csh +37 -0
- .venv/bin/activate.fish +75 -0
- .venv/bin/convert-caffe2-to-onnx +8 -0
- .venv/bin/convert-onnx-to-caffe2 +8 -0
- .venv/bin/easy_install +8 -0
- .venv/bin/easy_install-3.8 +8 -0
- .venv/bin/f2py +8 -0
- .venv/bin/f2py3 +8 -0
- .venv/bin/f2py3.8 +8 -0
- .venv/bin/fonttools +8 -0
- .venv/bin/futurize +8 -0
- .venv/bin/isympy +8 -0
- .venv/bin/normalizer +8 -0
- .venv/bin/numba +8 -0
- .venv/bin/pasteurize +8 -0
- .venv/bin/pip +8 -0
- .venv/bin/pip3 +8 -0
- .venv/bin/pip3.8 +8 -0
- .venv/bin/pyftmerge +8 -0
- .venv/bin/pyftsubset +8 -0
- .venv/bin/python +1 -0
- .venv/bin/python3 +1 -0
- .venv/bin/torchrun +8 -0
- .venv/bin/tqdm +8 -0
- .venv/bin/ttx +8 -0
- .venv/bin/wandb +8 -0
- .venv/bin/wb +8 -0
- .venv/pyvenv.cfg +3 -0
- .venv/share/doc/networkx-3.1/LICENSE.txt +37 -0
- .venv/share/doc/networkx-3.1/examples/3d_drawing/README.txt +2 -0
- .venv/share/doc/networkx-3.1/examples/3d_drawing/mayavi2_spring.py +43 -0
- .venv/share/doc/networkx-3.1/examples/3d_drawing/plot_basic.py +51 -0
- .venv/share/doc/networkx-3.1/examples/README.txt +8 -0
- .venv/share/doc/networkx-3.1/examples/algorithms/README.txt +2 -0
- .venv/share/doc/networkx-3.1/examples/algorithms/WormNet.v3.benchmark.txt +0 -0
- .venv/share/doc/networkx-3.1/examples/algorithms/hartford_drug.edgelist +338 -0
- .venv/share/doc/networkx-3.1/examples/algorithms/plot_beam_search.py +112 -0
- .venv/share/doc/networkx-3.1/examples/algorithms/plot_betweenness_centrality.py +83 -0
- .venv/share/doc/networkx-3.1/examples/algorithms/plot_blockmodel.py +79 -0
- .venv/share/doc/networkx-3.1/examples/algorithms/plot_circuits.py +103 -0
- .venv/share/doc/networkx-3.1/examples/algorithms/plot_davis_club.py +43 -0
- .venv/share/doc/networkx-3.1/examples/algorithms/plot_dedensification.py +92 -0
- .venv/share/doc/networkx-3.1/examples/algorithms/plot_girvan_newman.py +79 -0
- .venv/share/doc/networkx-3.1/examples/algorithms/plot_iterated_dynamical_systems.py +210 -0
- .venv/share/doc/networkx-3.1/examples/algorithms/plot_krackhardt_centrality.py +31 -0
- .venv/share/doc/networkx-3.1/examples/algorithms/plot_maximum_independent_set.py +44 -0
.gitattributes
ADDED
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
*.7z filter=lfs diff=lfs merge=lfs -text
|
2 |
+
*.arrow filter=lfs diff=lfs merge=lfs -text
|
3 |
+
*.bin filter=lfs diff=lfs merge=lfs -text
|
4 |
+
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
5 |
+
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
6 |
+
*.ftz filter=lfs diff=lfs merge=lfs -text
|
7 |
+
*.gz filter=lfs diff=lfs merge=lfs -text
|
8 |
+
*.h5 filter=lfs diff=lfs merge=lfs -text
|
9 |
+
*.joblib filter=lfs diff=lfs merge=lfs -text
|
10 |
+
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
11 |
+
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
12 |
+
*.model filter=lfs diff=lfs merge=lfs -text
|
13 |
+
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
14 |
+
*.npy filter=lfs diff=lfs merge=lfs -text
|
15 |
+
*.npz filter=lfs diff=lfs merge=lfs -text
|
16 |
+
*.onnx filter=lfs diff=lfs merge=lfs -text
|
17 |
+
*.ot filter=lfs diff=lfs merge=lfs -text
|
18 |
+
*.parquet filter=lfs diff=lfs merge=lfs -text
|
19 |
+
*.pb filter=lfs diff=lfs merge=lfs -text
|
20 |
+
*.pickle filter=lfs diff=lfs merge=lfs -text
|
21 |
+
*.pkl filter=lfs diff=lfs merge=lfs -text
|
22 |
+
*.pt filter=lfs diff=lfs merge=lfs -text
|
23 |
+
*.pth filter=lfs diff=lfs merge=lfs -text
|
24 |
+
*.rar filter=lfs diff=lfs merge=lfs -text
|
25 |
+
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
26 |
+
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
27 |
+
*.tflite filter=lfs diff=lfs merge=lfs -text
|
28 |
+
*.tgz filter=lfs diff=lfs merge=lfs -text
|
29 |
+
*.wasm filter=lfs diff=lfs merge=lfs -text
|
30 |
+
*.xz filter=lfs diff=lfs merge=lfs -text
|
31 |
+
*.zip filter=lfs diff=lfs merge=lfs -text
|
32 |
+
*.zst filter=lfs diff=lfs merge=lfs -text
|
33 |
+
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
.gitignore
ADDED
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Python
|
2 |
+
__pycache__/
|
3 |
+
*.py[cod]
|
4 |
+
*$py.class
|
5 |
+
*.so
|
6 |
+
.Python
|
7 |
+
build/
|
8 |
+
develop-eggs/
|
9 |
+
dist/
|
10 |
+
downloads/
|
11 |
+
eggs/
|
12 |
+
.eggs/
|
13 |
+
lib/
|
14 |
+
lib64/
|
15 |
+
parts/
|
16 |
+
sdist/
|
17 |
+
var/
|
18 |
+
wheels/
|
19 |
+
*.egg-info/
|
20 |
+
.installed.cfg
|
21 |
+
*.egg
|
22 |
+
|
23 |
+
# Virtual Environment
|
24 |
+
venv/
|
25 |
+
ENV/
|
26 |
+
|
27 |
+
# IDE
|
28 |
+
.idea/
|
29 |
+
.vscode/
|
30 |
+
*.swp
|
31 |
+
*.swo
|
32 |
+
|
33 |
+
# Project specific
|
34 |
+
temp/
|
35 |
+
wandb/
|
36 |
+
*.wav
|
37 |
+
*.mp3
|
38 |
+
*.flac
|
39 |
+
models/
|
40 |
+
checkpoints/
|
41 |
+
|
42 |
+
# Logs
|
43 |
+
*.log
|
44 |
+
logs/
|
.venv/bin/Activate.ps1
ADDED
@@ -0,0 +1,241 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<#
|
2 |
+
.Synopsis
|
3 |
+
Activate a Python virtual environment for the current PowerShell session.
|
4 |
+
|
5 |
+
.Description
|
6 |
+
Pushes the python executable for a virtual environment to the front of the
|
7 |
+
$Env:PATH environment variable and sets the prompt to signify that you are
|
8 |
+
in a Python virtual environment. Makes use of the command line switches as
|
9 |
+
well as the `pyvenv.cfg` file values present in the virtual environment.
|
10 |
+
|
11 |
+
.Parameter VenvDir
|
12 |
+
Path to the directory that contains the virtual environment to activate. The
|
13 |
+
default value for this is the parent of the directory that the Activate.ps1
|
14 |
+
script is located within.
|
15 |
+
|
16 |
+
.Parameter Prompt
|
17 |
+
The prompt prefix to display when this virtual environment is activated. By
|
18 |
+
default, this prompt is the name of the virtual environment folder (VenvDir)
|
19 |
+
surrounded by parentheses and followed by a single space (ie. '(.venv) ').
|
20 |
+
|
21 |
+
.Example
|
22 |
+
Activate.ps1
|
23 |
+
Activates the Python virtual environment that contains the Activate.ps1 script.
|
24 |
+
|
25 |
+
.Example
|
26 |
+
Activate.ps1 -Verbose
|
27 |
+
Activates the Python virtual environment that contains the Activate.ps1 script,
|
28 |
+
and shows extra information about the activation as it executes.
|
29 |
+
|
30 |
+
.Example
|
31 |
+
Activate.ps1 -VenvDir C:\Users\MyUser\Common\.venv
|
32 |
+
Activates the Python virtual environment located in the specified location.
|
33 |
+
|
34 |
+
.Example
|
35 |
+
Activate.ps1 -Prompt "MyPython"
|
36 |
+
Activates the Python virtual environment that contains the Activate.ps1 script,
|
37 |
+
and prefixes the current prompt with the specified string (surrounded in
|
38 |
+
parentheses) while the virtual environment is active.
|
39 |
+
|
40 |
+
.Notes
|
41 |
+
On Windows, it may be required to enable this Activate.ps1 script by setting the
|
42 |
+
execution policy for the user. You can do this by issuing the following PowerShell
|
43 |
+
command:
|
44 |
+
|
45 |
+
PS C:\> Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
|
46 |
+
|
47 |
+
For more information on Execution Policies:
|
48 |
+
https://go.microsoft.com/fwlink/?LinkID=135170
|
49 |
+
|
50 |
+
#>
|
51 |
+
Param(
|
52 |
+
[Parameter(Mandatory = $false)]
|
53 |
+
[String]
|
54 |
+
$VenvDir,
|
55 |
+
[Parameter(Mandatory = $false)]
|
56 |
+
[String]
|
57 |
+
$Prompt
|
58 |
+
)
|
59 |
+
|
60 |
+
<# Function declarations --------------------------------------------------- #>
|
61 |
+
|
62 |
+
<#
|
63 |
+
.Synopsis
|
64 |
+
Remove all shell session elements added by the Activate script, including the
|
65 |
+
addition of the virtual environment's Python executable from the beginning of
|
66 |
+
the PATH variable.
|
67 |
+
|
68 |
+
.Parameter NonDestructive
|
69 |
+
If present, do not remove this function from the global namespace for the
|
70 |
+
session.
|
71 |
+
|
72 |
+
#>
|
73 |
+
function global:deactivate ([switch]$NonDestructive) {
|
74 |
+
# Revert to original values
|
75 |
+
|
76 |
+
# The prior prompt:
|
77 |
+
if (Test-Path -Path Function:_OLD_VIRTUAL_PROMPT) {
|
78 |
+
Copy-Item -Path Function:_OLD_VIRTUAL_PROMPT -Destination Function:prompt
|
79 |
+
Remove-Item -Path Function:_OLD_VIRTUAL_PROMPT
|
80 |
+
}
|
81 |
+
|
82 |
+
# The prior PYTHONHOME:
|
83 |
+
if (Test-Path -Path Env:_OLD_VIRTUAL_PYTHONHOME) {
|
84 |
+
Copy-Item -Path Env:_OLD_VIRTUAL_PYTHONHOME -Destination Env:PYTHONHOME
|
85 |
+
Remove-Item -Path Env:_OLD_VIRTUAL_PYTHONHOME
|
86 |
+
}
|
87 |
+
|
88 |
+
# The prior PATH:
|
89 |
+
if (Test-Path -Path Env:_OLD_VIRTUAL_PATH) {
|
90 |
+
Copy-Item -Path Env:_OLD_VIRTUAL_PATH -Destination Env:PATH
|
91 |
+
Remove-Item -Path Env:_OLD_VIRTUAL_PATH
|
92 |
+
}
|
93 |
+
|
94 |
+
# Just remove the VIRTUAL_ENV altogether:
|
95 |
+
if (Test-Path -Path Env:VIRTUAL_ENV) {
|
96 |
+
Remove-Item -Path env:VIRTUAL_ENV
|
97 |
+
}
|
98 |
+
|
99 |
+
# Just remove the _PYTHON_VENV_PROMPT_PREFIX altogether:
|
100 |
+
if (Get-Variable -Name "_PYTHON_VENV_PROMPT_PREFIX" -ErrorAction SilentlyContinue) {
|
101 |
+
Remove-Variable -Name _PYTHON_VENV_PROMPT_PREFIX -Scope Global -Force
|
102 |
+
}
|
103 |
+
|
104 |
+
# Leave deactivate function in the global namespace if requested:
|
105 |
+
if (-not $NonDestructive) {
|
106 |
+
Remove-Item -Path function:deactivate
|
107 |
+
}
|
108 |
+
}
|
109 |
+
|
110 |
+
<#
|
111 |
+
.Description
|
112 |
+
Get-PyVenvConfig parses the values from the pyvenv.cfg file located in the
|
113 |
+
given folder, and returns them in a map.
|
114 |
+
|
115 |
+
For each line in the pyvenv.cfg file, if that line can be parsed into exactly
|
116 |
+
two strings separated by `=` (with any amount of whitespace surrounding the =)
|
117 |
+
then it is considered a `key = value` line. The left hand string is the key,
|
118 |
+
the right hand is the value.
|
119 |
+
|
120 |
+
If the value starts with a `'` or a `"` then the first and last character is
|
121 |
+
stripped from the value before being captured.
|
122 |
+
|
123 |
+
.Parameter ConfigDir
|
124 |
+
Path to the directory that contains the `pyvenv.cfg` file.
|
125 |
+
#>
|
126 |
+
function Get-PyVenvConfig(
|
127 |
+
[String]
|
128 |
+
$ConfigDir
|
129 |
+
) {
|
130 |
+
Write-Verbose "Given ConfigDir=$ConfigDir, obtain values in pyvenv.cfg"
|
131 |
+
|
132 |
+
# Ensure the file exists, and issue a warning if it doesn't (but still allow the function to continue).
|
133 |
+
$pyvenvConfigPath = Join-Path -Resolve -Path $ConfigDir -ChildPath 'pyvenv.cfg' -ErrorAction Continue
|
134 |
+
|
135 |
+
# An empty map will be returned if no config file is found.
|
136 |
+
$pyvenvConfig = @{ }
|
137 |
+
|
138 |
+
if ($pyvenvConfigPath) {
|
139 |
+
|
140 |
+
Write-Verbose "File exists, parse `key = value` lines"
|
141 |
+
$pyvenvConfigContent = Get-Content -Path $pyvenvConfigPath
|
142 |
+
|
143 |
+
$pyvenvConfigContent | ForEach-Object {
|
144 |
+
$keyval = $PSItem -split "\s*=\s*", 2
|
145 |
+
if ($keyval[0] -and $keyval[1]) {
|
146 |
+
$val = $keyval[1]
|
147 |
+
|
148 |
+
# Remove extraneous quotations around a string value.
|
149 |
+
if ("'""".Contains($val.Substring(0, 1))) {
|
150 |
+
$val = $val.Substring(1, $val.Length - 2)
|
151 |
+
}
|
152 |
+
|
153 |
+
$pyvenvConfig[$keyval[0]] = $val
|
154 |
+
Write-Verbose "Adding Key: '$($keyval[0])'='$val'"
|
155 |
+
}
|
156 |
+
}
|
157 |
+
}
|
158 |
+
return $pyvenvConfig
|
159 |
+
}
|
160 |
+
|
161 |
+
|
162 |
+
<# Begin Activate script --------------------------------------------------- #>
|
163 |
+
|
164 |
+
# Determine the containing directory of this script
|
165 |
+
$VenvExecPath = Split-Path -Parent $MyInvocation.MyCommand.Definition
|
166 |
+
$VenvExecDir = Get-Item -Path $VenvExecPath
|
167 |
+
|
168 |
+
Write-Verbose "Activation script is located in path: '$VenvExecPath'"
|
169 |
+
Write-Verbose "VenvExecDir Fullname: '$($VenvExecDir.FullName)"
|
170 |
+
Write-Verbose "VenvExecDir Name: '$($VenvExecDir.Name)"
|
171 |
+
|
172 |
+
# Set values required in priority: CmdLine, ConfigFile, Default
|
173 |
+
# First, get the location of the virtual environment, it might not be
|
174 |
+
# VenvExecDir if specified on the command line.
|
175 |
+
if ($VenvDir) {
|
176 |
+
Write-Verbose "VenvDir given as parameter, using '$VenvDir' to determine values"
|
177 |
+
}
|
178 |
+
else {
|
179 |
+
Write-Verbose "VenvDir not given as a parameter, using parent directory name as VenvDir."
|
180 |
+
$VenvDir = $VenvExecDir.Parent.FullName.TrimEnd("\\/")
|
181 |
+
Write-Verbose "VenvDir=$VenvDir"
|
182 |
+
}
|
183 |
+
|
184 |
+
# Next, read the `pyvenv.cfg` file to determine any required value such
|
185 |
+
# as `prompt`.
|
186 |
+
$pyvenvCfg = Get-PyVenvConfig -ConfigDir $VenvDir
|
187 |
+
|
188 |
+
# Next, set the prompt from the command line, or the config file, or
|
189 |
+
# just use the name of the virtual environment folder.
|
190 |
+
if ($Prompt) {
|
191 |
+
Write-Verbose "Prompt specified as argument, using '$Prompt'"
|
192 |
+
}
|
193 |
+
else {
|
194 |
+
Write-Verbose "Prompt not specified as argument to script, checking pyvenv.cfg value"
|
195 |
+
if ($pyvenvCfg -and $pyvenvCfg['prompt']) {
|
196 |
+
Write-Verbose " Setting based on value in pyvenv.cfg='$($pyvenvCfg['prompt'])'"
|
197 |
+
$Prompt = $pyvenvCfg['prompt'];
|
198 |
+
}
|
199 |
+
else {
|
200 |
+
Write-Verbose " Setting prompt based on parent's directory's name. (Is the directory name passed to venv module when creating the virutal environment)"
|
201 |
+
Write-Verbose " Got leaf-name of $VenvDir='$(Split-Path -Path $venvDir -Leaf)'"
|
202 |
+
$Prompt = Split-Path -Path $venvDir -Leaf
|
203 |
+
}
|
204 |
+
}
|
205 |
+
|
206 |
+
Write-Verbose "Prompt = '$Prompt'"
|
207 |
+
Write-Verbose "VenvDir='$VenvDir'"
|
208 |
+
|
209 |
+
# Deactivate any currently active virtual environment, but leave the
|
210 |
+
# deactivate function in place.
|
211 |
+
deactivate -nondestructive
|
212 |
+
|
213 |
+
# Now set the environment variable VIRTUAL_ENV, used by many tools to determine
|
214 |
+
# that there is an activated venv.
|
215 |
+
$env:VIRTUAL_ENV = $VenvDir
|
216 |
+
|
217 |
+
if (-not $Env:VIRTUAL_ENV_DISABLE_PROMPT) {
|
218 |
+
|
219 |
+
Write-Verbose "Setting prompt to '$Prompt'"
|
220 |
+
|
221 |
+
# Set the prompt to include the env name
|
222 |
+
# Make sure _OLD_VIRTUAL_PROMPT is global
|
223 |
+
function global:_OLD_VIRTUAL_PROMPT { "" }
|
224 |
+
Copy-Item -Path function:prompt -Destination function:_OLD_VIRTUAL_PROMPT
|
225 |
+
New-Variable -Name _PYTHON_VENV_PROMPT_PREFIX -Description "Python virtual environment prompt prefix" -Scope Global -Option ReadOnly -Visibility Public -Value $Prompt
|
226 |
+
|
227 |
+
function global:prompt {
|
228 |
+
Write-Host -NoNewline -ForegroundColor Green "($_PYTHON_VENV_PROMPT_PREFIX) "
|
229 |
+
_OLD_VIRTUAL_PROMPT
|
230 |
+
}
|
231 |
+
}
|
232 |
+
|
233 |
+
# Clear PYTHONHOME
|
234 |
+
if (Test-Path -Path Env:PYTHONHOME) {
|
235 |
+
Copy-Item -Path Env:PYTHONHOME -Destination Env:_OLD_VIRTUAL_PYTHONHOME
|
236 |
+
Remove-Item -Path Env:PYTHONHOME
|
237 |
+
}
|
238 |
+
|
239 |
+
# Add the venv to the PATH
|
240 |
+
Copy-Item -Path Env:PATH -Destination Env:_OLD_VIRTUAL_PATH
|
241 |
+
$Env:PATH = "$VenvExecDir$([System.IO.Path]::PathSeparator)$Env:PATH"
|
.venv/bin/activate
ADDED
@@ -0,0 +1,76 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# This file must be used with "source bin/activate" *from bash*
|
2 |
+
# you cannot run it directly
|
3 |
+
|
4 |
+
deactivate () {
|
5 |
+
# reset old environment variables
|
6 |
+
if [ -n "${_OLD_VIRTUAL_PATH:-}" ] ; then
|
7 |
+
PATH="${_OLD_VIRTUAL_PATH:-}"
|
8 |
+
export PATH
|
9 |
+
unset _OLD_VIRTUAL_PATH
|
10 |
+
fi
|
11 |
+
if [ -n "${_OLD_VIRTUAL_PYTHONHOME:-}" ] ; then
|
12 |
+
PYTHONHOME="${_OLD_VIRTUAL_PYTHONHOME:-}"
|
13 |
+
export PYTHONHOME
|
14 |
+
unset _OLD_VIRTUAL_PYTHONHOME
|
15 |
+
fi
|
16 |
+
|
17 |
+
# This should detect bash and zsh, which have a hash command that must
|
18 |
+
# be called to get it to forget past commands. Without forgetting
|
19 |
+
# past commands the $PATH changes we made may not be respected
|
20 |
+
if [ -n "${BASH:-}" -o -n "${ZSH_VERSION:-}" ] ; then
|
21 |
+
hash -r
|
22 |
+
fi
|
23 |
+
|
24 |
+
if [ -n "${_OLD_VIRTUAL_PS1:-}" ] ; then
|
25 |
+
PS1="${_OLD_VIRTUAL_PS1:-}"
|
26 |
+
export PS1
|
27 |
+
unset _OLD_VIRTUAL_PS1
|
28 |
+
fi
|
29 |
+
|
30 |
+
unset VIRTUAL_ENV
|
31 |
+
if [ ! "${1:-}" = "nondestructive" ] ; then
|
32 |
+
# Self destruct!
|
33 |
+
unset -f deactivate
|
34 |
+
fi
|
35 |
+
}
|
36 |
+
|
37 |
+
# unset irrelevant variables
|
38 |
+
deactivate nondestructive
|
39 |
+
|
40 |
+
VIRTUAL_ENV="/Users/yangdajing/Desktop/voice_clone_app/.venv"
|
41 |
+
export VIRTUAL_ENV
|
42 |
+
|
43 |
+
_OLD_VIRTUAL_PATH="$PATH"
|
44 |
+
PATH="$VIRTUAL_ENV/bin:$PATH"
|
45 |
+
export PATH
|
46 |
+
|
47 |
+
# unset PYTHONHOME if set
|
48 |
+
# this will fail if PYTHONHOME is set to the empty string (which is bad anyway)
|
49 |
+
# could use `if (set -u; : $PYTHONHOME) ;` in bash
|
50 |
+
if [ -n "${PYTHONHOME:-}" ] ; then
|
51 |
+
_OLD_VIRTUAL_PYTHONHOME="${PYTHONHOME:-}"
|
52 |
+
unset PYTHONHOME
|
53 |
+
fi
|
54 |
+
|
55 |
+
if [ -z "${VIRTUAL_ENV_DISABLE_PROMPT:-}" ] ; then
|
56 |
+
_OLD_VIRTUAL_PS1="${PS1:-}"
|
57 |
+
if [ "x(.venv) " != x ] ; then
|
58 |
+
PS1="(.venv) ${PS1:-}"
|
59 |
+
else
|
60 |
+
if [ "`basename \"$VIRTUAL_ENV\"`" = "__" ] ; then
|
61 |
+
# special case for Aspen magic directories
|
62 |
+
# see http://www.zetadev.com/software/aspen/
|
63 |
+
PS1="[`basename \`dirname \"$VIRTUAL_ENV\"\``] $PS1"
|
64 |
+
else
|
65 |
+
PS1="(`basename \"$VIRTUAL_ENV\"`)$PS1"
|
66 |
+
fi
|
67 |
+
fi
|
68 |
+
export PS1
|
69 |
+
fi
|
70 |
+
|
71 |
+
# This should detect bash and zsh, which have a hash command that must
|
72 |
+
# be called to get it to forget past commands. Without forgetting
|
73 |
+
# past commands the $PATH changes we made may not be respected
|
74 |
+
if [ -n "${BASH:-}" -o -n "${ZSH_VERSION:-}" ] ; then
|
75 |
+
hash -r
|
76 |
+
fi
|
.venv/bin/activate.csh
ADDED
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# This file must be used with "source bin/activate.csh" *from csh*.
|
2 |
+
# You cannot run it directly.
|
3 |
+
# Created by Davide Di Blasi <[email protected]>.
|
4 |
+
# Ported to Python 3.3 venv by Andrew Svetlov <[email protected]>
|
5 |
+
|
6 |
+
alias deactivate 'test $?_OLD_VIRTUAL_PATH != 0 && setenv PATH "$_OLD_VIRTUAL_PATH" && unset _OLD_VIRTUAL_PATH; rehash; test $?_OLD_VIRTUAL_PROMPT != 0 && set prompt="$_OLD_VIRTUAL_PROMPT" && unset _OLD_VIRTUAL_PROMPT; unsetenv VIRTUAL_ENV; test "\!:*" != "nondestructive" && unalias deactivate'
|
7 |
+
|
8 |
+
# Unset irrelevant variables.
|
9 |
+
deactivate nondestructive
|
10 |
+
|
11 |
+
setenv VIRTUAL_ENV "/Users/yangdajing/Desktop/voice_clone_app/.venv"
|
12 |
+
|
13 |
+
set _OLD_VIRTUAL_PATH="$PATH"
|
14 |
+
setenv PATH "$VIRTUAL_ENV/bin:$PATH"
|
15 |
+
|
16 |
+
|
17 |
+
set _OLD_VIRTUAL_PROMPT="$prompt"
|
18 |
+
|
19 |
+
if (! "$?VIRTUAL_ENV_DISABLE_PROMPT") then
|
20 |
+
if (".venv" != "") then
|
21 |
+
set env_name = ".venv"
|
22 |
+
else
|
23 |
+
if (`basename "VIRTUAL_ENV"` == "__") then
|
24 |
+
# special case for Aspen magic directories
|
25 |
+
# see http://www.zetadev.com/software/aspen/
|
26 |
+
set env_name = `basename \`dirname "$VIRTUAL_ENV"\``
|
27 |
+
else
|
28 |
+
set env_name = `basename "$VIRTUAL_ENV"`
|
29 |
+
endif
|
30 |
+
endif
|
31 |
+
set prompt = "[$env_name] $prompt"
|
32 |
+
unset env_name
|
33 |
+
endif
|
34 |
+
|
35 |
+
alias pydoc python -m pydoc
|
36 |
+
|
37 |
+
rehash
|
.venv/bin/activate.fish
ADDED
@@ -0,0 +1,75 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# This file must be used with ". bin/activate.fish" *from fish* (http://fishshell.org)
|
2 |
+
# you cannot run it directly
|
3 |
+
|
4 |
+
function deactivate -d "Exit virtualenv and return to normal shell environment"
|
5 |
+
# reset old environment variables
|
6 |
+
if test -n "$_OLD_VIRTUAL_PATH"
|
7 |
+
set -gx PATH $_OLD_VIRTUAL_PATH
|
8 |
+
set -e _OLD_VIRTUAL_PATH
|
9 |
+
end
|
10 |
+
if test -n "$_OLD_VIRTUAL_PYTHONHOME"
|
11 |
+
set -gx PYTHONHOME $_OLD_VIRTUAL_PYTHONHOME
|
12 |
+
set -e _OLD_VIRTUAL_PYTHONHOME
|
13 |
+
end
|
14 |
+
|
15 |
+
if test -n "$_OLD_FISH_PROMPT_OVERRIDE"
|
16 |
+
functions -e fish_prompt
|
17 |
+
set -e _OLD_FISH_PROMPT_OVERRIDE
|
18 |
+
functions -c _old_fish_prompt fish_prompt
|
19 |
+
functions -e _old_fish_prompt
|
20 |
+
end
|
21 |
+
|
22 |
+
set -e VIRTUAL_ENV
|
23 |
+
if test "$argv[1]" != "nondestructive"
|
24 |
+
# Self destruct!
|
25 |
+
functions -e deactivate
|
26 |
+
end
|
27 |
+
end
|
28 |
+
|
29 |
+
# unset irrelevant variables
|
30 |
+
deactivate nondestructive
|
31 |
+
|
32 |
+
set -gx VIRTUAL_ENV "/Users/yangdajing/Desktop/voice_clone_app/.venv"
|
33 |
+
|
34 |
+
set -gx _OLD_VIRTUAL_PATH $PATH
|
35 |
+
set -gx PATH "$VIRTUAL_ENV/bin" $PATH
|
36 |
+
|
37 |
+
# unset PYTHONHOME if set
|
38 |
+
if set -q PYTHONHOME
|
39 |
+
set -gx _OLD_VIRTUAL_PYTHONHOME $PYTHONHOME
|
40 |
+
set -e PYTHONHOME
|
41 |
+
end
|
42 |
+
|
43 |
+
if test -z "$VIRTUAL_ENV_DISABLE_PROMPT"
|
44 |
+
# fish uses a function instead of an env var to generate the prompt.
|
45 |
+
|
46 |
+
# save the current fish_prompt function as the function _old_fish_prompt
|
47 |
+
functions -c fish_prompt _old_fish_prompt
|
48 |
+
|
49 |
+
# with the original prompt function renamed, we can override with our own.
|
50 |
+
function fish_prompt
|
51 |
+
# Save the return status of the last command
|
52 |
+
set -l old_status $status
|
53 |
+
|
54 |
+
# Prompt override?
|
55 |
+
if test -n "(.venv) "
|
56 |
+
printf "%s%s" "(.venv) " (set_color normal)
|
57 |
+
else
|
58 |
+
# ...Otherwise, prepend env
|
59 |
+
set -l _checkbase (basename "$VIRTUAL_ENV")
|
60 |
+
if test $_checkbase = "__"
|
61 |
+
# special case for Aspen magic directories
|
62 |
+
# see http://www.zetadev.com/software/aspen/
|
63 |
+
printf "%s[%s]%s " (set_color -b blue white) (basename (dirname "$VIRTUAL_ENV")) (set_color normal)
|
64 |
+
else
|
65 |
+
printf "%s(%s)%s" (set_color -b blue white) (basename "$VIRTUAL_ENV") (set_color normal)
|
66 |
+
end
|
67 |
+
end
|
68 |
+
|
69 |
+
# Restore the return status of the previous command.
|
70 |
+
echo "exit $old_status" | .
|
71 |
+
_old_fish_prompt
|
72 |
+
end
|
73 |
+
|
74 |
+
set -gx _OLD_FISH_PROMPT_OVERRIDE "$VIRTUAL_ENV"
|
75 |
+
end
|
.venv/bin/convert-caffe2-to-onnx
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/Users/yangdajing/Desktop/voice_clone_app/.venv/bin/python
|
2 |
+
# -*- coding: utf-8 -*-
|
3 |
+
import re
|
4 |
+
import sys
|
5 |
+
from caffe2.python.onnx.bin.conversion import caffe2_to_onnx
|
6 |
+
if __name__ == '__main__':
|
7 |
+
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
8 |
+
sys.exit(caffe2_to_onnx())
|
.venv/bin/convert-onnx-to-caffe2
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/Users/yangdajing/Desktop/voice_clone_app/.venv/bin/python
|
2 |
+
# -*- coding: utf-8 -*-
|
3 |
+
import re
|
4 |
+
import sys
|
5 |
+
from caffe2.python.onnx.bin.conversion import onnx_to_caffe2
|
6 |
+
if __name__ == '__main__':
|
7 |
+
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
8 |
+
sys.exit(onnx_to_caffe2())
|
.venv/bin/easy_install
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/Users/yangdajing/Desktop/voice_clone_app/.venv/bin/python3
|
2 |
+
# -*- coding: utf-8 -*-
|
3 |
+
import re
|
4 |
+
import sys
|
5 |
+
from setuptools.command.easy_install import main
|
6 |
+
if __name__ == '__main__':
|
7 |
+
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
8 |
+
sys.exit(main())
|
.venv/bin/easy_install-3.8
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/Users/yangdajing/Desktop/voice_clone_app/.venv/bin/python3
|
2 |
+
# -*- coding: utf-8 -*-
|
3 |
+
import re
|
4 |
+
import sys
|
5 |
+
from setuptools.command.easy_install import main
|
6 |
+
if __name__ == '__main__':
|
7 |
+
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
8 |
+
sys.exit(main())
|
.venv/bin/f2py
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/Users/yangdajing/Desktop/voice_clone_app/.venv/bin/python
|
2 |
+
# -*- coding: utf-8 -*-
|
3 |
+
import re
|
4 |
+
import sys
|
5 |
+
from numpy.f2py.f2py2e import main
|
6 |
+
if __name__ == '__main__':
|
7 |
+
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
8 |
+
sys.exit(main())
|
.venv/bin/f2py3
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/Users/yangdajing/Desktop/voice_clone_app/.venv/bin/python
|
2 |
+
# -*- coding: utf-8 -*-
|
3 |
+
import re
|
4 |
+
import sys
|
5 |
+
from numpy.f2py.f2py2e import main
|
6 |
+
if __name__ == '__main__':
|
7 |
+
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
8 |
+
sys.exit(main())
|
.venv/bin/f2py3.8
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/Users/yangdajing/Desktop/voice_clone_app/.venv/bin/python
|
2 |
+
# -*- coding: utf-8 -*-
|
3 |
+
import re
|
4 |
+
import sys
|
5 |
+
from numpy.f2py.f2py2e import main
|
6 |
+
if __name__ == '__main__':
|
7 |
+
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
8 |
+
sys.exit(main())
|
.venv/bin/fonttools
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/Users/yangdajing/Desktop/voice_clone_app/.venv/bin/python
|
2 |
+
# -*- coding: utf-8 -*-
|
3 |
+
import re
|
4 |
+
import sys
|
5 |
+
from fontTools.__main__ import main
|
6 |
+
if __name__ == '__main__':
|
7 |
+
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
8 |
+
sys.exit(main())
|
.venv/bin/futurize
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/Users/yangdajing/Desktop/voice_clone_app/.venv/bin/python
|
2 |
+
# -*- coding: utf-8 -*-
|
3 |
+
import re
|
4 |
+
import sys
|
5 |
+
from libfuturize.main import main
|
6 |
+
if __name__ == '__main__':
|
7 |
+
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
8 |
+
sys.exit(main())
|
.venv/bin/isympy
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/Users/yangdajing/Desktop/voice_clone_app/.venv/bin/python
|
2 |
+
# -*- coding: utf-8 -*-
|
3 |
+
import re
|
4 |
+
import sys
|
5 |
+
from isympy import main
|
6 |
+
if __name__ == '__main__':
|
7 |
+
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
8 |
+
sys.exit(main())
|
.venv/bin/normalizer
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/Users/yangdajing/Desktop/voice_clone_app/.venv/bin/python
|
2 |
+
# -*- coding: utf-8 -*-
|
3 |
+
import re
|
4 |
+
import sys
|
5 |
+
from charset_normalizer import cli
|
6 |
+
if __name__ == '__main__':
|
7 |
+
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
8 |
+
sys.exit(cli.cli_detect())
|
.venv/bin/numba
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/Users/yangdajing/Desktop/voice_clone_app/.venv/bin/python
|
2 |
+
# -*- coding: UTF-8 -*-
|
3 |
+
from __future__ import print_function, division, absolute_import
|
4 |
+
|
5 |
+
from numba.misc.numba_entry import main
|
6 |
+
|
7 |
+
if __name__ == "__main__":
|
8 |
+
main()
|
.venv/bin/pasteurize
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/Users/yangdajing/Desktop/voice_clone_app/.venv/bin/python
|
2 |
+
# -*- coding: utf-8 -*-
|
3 |
+
import re
|
4 |
+
import sys
|
5 |
+
from libpasteurize.main import main
|
6 |
+
if __name__ == '__main__':
|
7 |
+
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
8 |
+
sys.exit(main())
|
.venv/bin/pip
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/Users/yangdajing/Desktop/voice_clone_app/.venv/bin/python
|
2 |
+
# -*- coding: utf-8 -*-
|
3 |
+
import re
|
4 |
+
import sys
|
5 |
+
from pip._internal.cli.main import main
|
6 |
+
if __name__ == '__main__':
|
7 |
+
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
8 |
+
sys.exit(main())
|
.venv/bin/pip3
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/Users/yangdajing/Desktop/voice_clone_app/.venv/bin/python
|
2 |
+
# -*- coding: utf-8 -*-
|
3 |
+
import re
|
4 |
+
import sys
|
5 |
+
from pip._internal.cli.main import main
|
6 |
+
if __name__ == '__main__':
|
7 |
+
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
8 |
+
sys.exit(main())
|
.venv/bin/pip3.8
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/Users/yangdajing/Desktop/voice_clone_app/.venv/bin/python
|
2 |
+
# -*- coding: utf-8 -*-
|
3 |
+
import re
|
4 |
+
import sys
|
5 |
+
from pip._internal.cli.main import main
|
6 |
+
if __name__ == '__main__':
|
7 |
+
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
8 |
+
sys.exit(main())
|
.venv/bin/pyftmerge
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/Users/yangdajing/Desktop/voice_clone_app/.venv/bin/python
|
2 |
+
# -*- coding: utf-8 -*-
|
3 |
+
import re
|
4 |
+
import sys
|
5 |
+
from fontTools.merge import main
|
6 |
+
if __name__ == '__main__':
|
7 |
+
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
8 |
+
sys.exit(main())
|
.venv/bin/pyftsubset
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/Users/yangdajing/Desktop/voice_clone_app/.venv/bin/python
|
2 |
+
# -*- coding: utf-8 -*-
|
3 |
+
import re
|
4 |
+
import sys
|
5 |
+
from fontTools.subset import main
|
6 |
+
if __name__ == '__main__':
|
7 |
+
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
8 |
+
sys.exit(main())
|
.venv/bin/python
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
python3
|
.venv/bin/python3
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
/usr/local/bin/python3
|
.venv/bin/torchrun
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/Users/yangdajing/Desktop/voice_clone_app/.venv/bin/python
|
2 |
+
# -*- coding: utf-8 -*-
|
3 |
+
import re
|
4 |
+
import sys
|
5 |
+
from torch.distributed.run import main
|
6 |
+
if __name__ == '__main__':
|
7 |
+
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
8 |
+
sys.exit(main())
|
.venv/bin/tqdm
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/Users/yangdajing/Desktop/voice_clone_app/.venv/bin/python
|
2 |
+
# -*- coding: utf-8 -*-
|
3 |
+
import re
|
4 |
+
import sys
|
5 |
+
from tqdm.cli import main
|
6 |
+
if __name__ == '__main__':
|
7 |
+
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
8 |
+
sys.exit(main())
|
.venv/bin/ttx
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/Users/yangdajing/Desktop/voice_clone_app/.venv/bin/python
|
2 |
+
# -*- coding: utf-8 -*-
|
3 |
+
import re
|
4 |
+
import sys
|
5 |
+
from fontTools.ttx import main
|
6 |
+
if __name__ == '__main__':
|
7 |
+
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
8 |
+
sys.exit(main())
|
.venv/bin/wandb
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/Users/yangdajing/Desktop/voice_clone_app/.venv/bin/python
|
2 |
+
# -*- coding: utf-8 -*-
|
3 |
+
import re
|
4 |
+
import sys
|
5 |
+
from wandb.cli.cli import cli
|
6 |
+
if __name__ == '__main__':
|
7 |
+
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
8 |
+
sys.exit(cli())
|
.venv/bin/wb
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/Users/yangdajing/Desktop/voice_clone_app/.venv/bin/python
|
2 |
+
# -*- coding: utf-8 -*-
|
3 |
+
import re
|
4 |
+
import sys
|
5 |
+
from wandb.cli.cli import cli
|
6 |
+
if __name__ == '__main__':
|
7 |
+
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
8 |
+
sys.exit(cli())
|
.venv/pyvenv.cfg
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
home = /usr/local/bin
|
2 |
+
include-system-site-packages = false
|
3 |
+
version = 3.8.5
|
.venv/share/doc/networkx-3.1/LICENSE.txt
ADDED
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
NetworkX is distributed with the 3-clause BSD license.
|
2 |
+
|
3 |
+
::
|
4 |
+
|
5 |
+
Copyright (C) 2004-2023, NetworkX Developers
|
6 |
+
Aric Hagberg <[email protected]>
|
7 |
+
Dan Schult <[email protected]>
|
8 |
+
Pieter Swart <[email protected]>
|
9 |
+
All rights reserved.
|
10 |
+
|
11 |
+
Redistribution and use in source and binary forms, with or without
|
12 |
+
modification, are permitted provided that the following conditions are
|
13 |
+
met:
|
14 |
+
|
15 |
+
* Redistributions of source code must retain the above copyright
|
16 |
+
notice, this list of conditions and the following disclaimer.
|
17 |
+
|
18 |
+
* Redistributions in binary form must reproduce the above
|
19 |
+
copyright notice, this list of conditions and the following
|
20 |
+
disclaimer in the documentation and/or other materials provided
|
21 |
+
with the distribution.
|
22 |
+
|
23 |
+
* Neither the name of the NetworkX Developers nor the names of its
|
24 |
+
contributors may be used to endorse or promote products derived
|
25 |
+
from this software without specific prior written permission.
|
26 |
+
|
27 |
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
28 |
+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
29 |
+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
30 |
+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
31 |
+
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
32 |
+
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
33 |
+
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
34 |
+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
35 |
+
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
36 |
+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
37 |
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
.venv/share/doc/networkx-3.1/examples/3d_drawing/README.txt
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
3D Drawing
|
2 |
+
----------
|
.venv/share/doc/networkx-3.1/examples/3d_drawing/mayavi2_spring.py
ADDED
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"""
|
2 |
+
=======
|
3 |
+
Mayavi2
|
4 |
+
=======
|
5 |
+
|
6 |
+
"""
|
7 |
+
|
8 |
+
import networkx as nx
|
9 |
+
import numpy as np
|
10 |
+
from mayavi import mlab
|
11 |
+
|
12 |
+
# some graphs to try
|
13 |
+
# H=nx.krackhardt_kite_graph()
|
14 |
+
# H=nx.Graph();H.add_edge('a','b');H.add_edge('a','c');H.add_edge('a','d')
|
15 |
+
# H=nx.grid_2d_graph(4,5)
|
16 |
+
H = nx.cycle_graph(20)
|
17 |
+
|
18 |
+
# reorder nodes from 0,len(G)-1
|
19 |
+
G = nx.convert_node_labels_to_integers(H)
|
20 |
+
# 3d spring layout
|
21 |
+
pos = nx.spring_layout(G, dim=3, seed=1001)
|
22 |
+
# numpy array of x,y,z positions in sorted node order
|
23 |
+
xyz = np.array([pos[v] for v in sorted(G)])
|
24 |
+
# scalar colors
|
25 |
+
scalars = np.array(list(G.nodes())) + 5
|
26 |
+
|
27 |
+
mlab.figure()
|
28 |
+
|
29 |
+
pts = mlab.points3d(
|
30 |
+
xyz[:, 0],
|
31 |
+
xyz[:, 1],
|
32 |
+
xyz[:, 2],
|
33 |
+
scalars,
|
34 |
+
scale_factor=0.1,
|
35 |
+
scale_mode="none",
|
36 |
+
colormap="Blues",
|
37 |
+
resolution=20,
|
38 |
+
)
|
39 |
+
|
40 |
+
pts.mlab_source.dataset.lines = np.array(list(G.edges()))
|
41 |
+
tube = mlab.pipeline.tube(pts, tube_radius=0.01)
|
42 |
+
mlab.pipeline.surface(tube, color=(0.8, 0.8, 0.8))
|
43 |
+
mlab.orientation_axes()
|
.venv/share/doc/networkx-3.1/examples/3d_drawing/plot_basic.py
ADDED
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"""
|
2 |
+
================
|
3 |
+
Basic matplotlib
|
4 |
+
================
|
5 |
+
|
6 |
+
A basic example of 3D Graph visualization using `mpl_toolkits.mplot_3d`.
|
7 |
+
|
8 |
+
"""
|
9 |
+
|
10 |
+
import networkx as nx
|
11 |
+
import numpy as np
|
12 |
+
import matplotlib.pyplot as plt
|
13 |
+
from mpl_toolkits.mplot3d import Axes3D
|
14 |
+
|
15 |
+
# The graph to visualize
|
16 |
+
G = nx.cycle_graph(20)
|
17 |
+
|
18 |
+
# 3d spring layout
|
19 |
+
pos = nx.spring_layout(G, dim=3, seed=779)
|
20 |
+
# Extract node and edge positions from the layout
|
21 |
+
node_xyz = np.array([pos[v] for v in sorted(G)])
|
22 |
+
edge_xyz = np.array([(pos[u], pos[v]) for u, v in G.edges()])
|
23 |
+
|
24 |
+
# Create the 3D figure
|
25 |
+
fig = plt.figure()
|
26 |
+
ax = fig.add_subplot(111, projection="3d")
|
27 |
+
|
28 |
+
# Plot the nodes - alpha is scaled by "depth" automatically
|
29 |
+
ax.scatter(*node_xyz.T, s=100, ec="w")
|
30 |
+
|
31 |
+
# Plot the edges
|
32 |
+
for vizedge in edge_xyz:
|
33 |
+
ax.plot(*vizedge.T, color="tab:gray")
|
34 |
+
|
35 |
+
|
36 |
+
def _format_axes(ax):
|
37 |
+
"""Visualization options for the 3D axes."""
|
38 |
+
# Turn gridlines off
|
39 |
+
ax.grid(False)
|
40 |
+
# Suppress tick labels
|
41 |
+
for dim in (ax.xaxis, ax.yaxis, ax.zaxis):
|
42 |
+
dim.set_ticks([])
|
43 |
+
# Set axes labels
|
44 |
+
ax.set_xlabel("x")
|
45 |
+
ax.set_ylabel("y")
|
46 |
+
ax.set_zlabel("z")
|
47 |
+
|
48 |
+
|
49 |
+
_format_axes(ax)
|
50 |
+
fig.tight_layout()
|
51 |
+
plt.show()
|
.venv/share/doc/networkx-3.1/examples/README.txt
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
.. _examples_gallery:
|
2 |
+
|
3 |
+
Gallery
|
4 |
+
=======
|
5 |
+
|
6 |
+
General-purpose and introductory examples for NetworkX.
|
7 |
+
The `tutorial <../tutorial.html>`_ introduces conventions and basic graph
|
8 |
+
manipulations.
|
.venv/share/doc/networkx-3.1/examples/algorithms/README.txt
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
Algorithms
|
2 |
+
----------
|
.venv/share/doc/networkx-3.1/examples/algorithms/WormNet.v3.benchmark.txt
ADDED
The diff for this file is too large to render.
See raw diff
|
|
.venv/share/doc/networkx-3.1/examples/algorithms/hartford_drug.edgelist
ADDED
@@ -0,0 +1,338 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# source target
|
2 |
+
1 2
|
3 |
+
1 10
|
4 |
+
2 1
|
5 |
+
2 10
|
6 |
+
3 7
|
7 |
+
4 7
|
8 |
+
4 209
|
9 |
+
5 132
|
10 |
+
6 150
|
11 |
+
7 3
|
12 |
+
7 4
|
13 |
+
7 9
|
14 |
+
8 106
|
15 |
+
8 115
|
16 |
+
9 1
|
17 |
+
9 2
|
18 |
+
9 7
|
19 |
+
10 1
|
20 |
+
10 2
|
21 |
+
11 133
|
22 |
+
11 218
|
23 |
+
12 88
|
24 |
+
13 214
|
25 |
+
14 24
|
26 |
+
14 52
|
27 |
+
16 10
|
28 |
+
16 19
|
29 |
+
17 64
|
30 |
+
17 78
|
31 |
+
18 55
|
32 |
+
18 103
|
33 |
+
18 163
|
34 |
+
19 18
|
35 |
+
20 64
|
36 |
+
20 180
|
37 |
+
21 16
|
38 |
+
21 22
|
39 |
+
22 21
|
40 |
+
22 64
|
41 |
+
22 106
|
42 |
+
23 20
|
43 |
+
23 22
|
44 |
+
23 64
|
45 |
+
24 14
|
46 |
+
24 31
|
47 |
+
24 122
|
48 |
+
27 115
|
49 |
+
28 29
|
50 |
+
29 28
|
51 |
+
30 19
|
52 |
+
31 24
|
53 |
+
31 32
|
54 |
+
31 122
|
55 |
+
31 147
|
56 |
+
31 233
|
57 |
+
32 31
|
58 |
+
32 86
|
59 |
+
34 35
|
60 |
+
34 37
|
61 |
+
35 34
|
62 |
+
35 43
|
63 |
+
36 132
|
64 |
+
36 187
|
65 |
+
37 38
|
66 |
+
37 90
|
67 |
+
37 282
|
68 |
+
38 42
|
69 |
+
38 43
|
70 |
+
38 210
|
71 |
+
40 20
|
72 |
+
42 15
|
73 |
+
42 38
|
74 |
+
43 34
|
75 |
+
43 35
|
76 |
+
43 38
|
77 |
+
45 107
|
78 |
+
46 61
|
79 |
+
46 72
|
80 |
+
48 23
|
81 |
+
49 30
|
82 |
+
49 64
|
83 |
+
49 108
|
84 |
+
49 115
|
85 |
+
49 243
|
86 |
+
50 30
|
87 |
+
50 47
|
88 |
+
50 55
|
89 |
+
50 125
|
90 |
+
50 163
|
91 |
+
52 218
|
92 |
+
52 224
|
93 |
+
54 111
|
94 |
+
54 210
|
95 |
+
55 65
|
96 |
+
55 67
|
97 |
+
55 105
|
98 |
+
55 108
|
99 |
+
55 222
|
100 |
+
56 18
|
101 |
+
56 64
|
102 |
+
57 65
|
103 |
+
57 125
|
104 |
+
58 20
|
105 |
+
58 30
|
106 |
+
58 50
|
107 |
+
58 103
|
108 |
+
58 180
|
109 |
+
59 164
|
110 |
+
63 125
|
111 |
+
64 8
|
112 |
+
64 50
|
113 |
+
64 70
|
114 |
+
64 256
|
115 |
+
66 20
|
116 |
+
66 84
|
117 |
+
66 106
|
118 |
+
66 125
|
119 |
+
67 22
|
120 |
+
67 50
|
121 |
+
67 113
|
122 |
+
68 50
|
123 |
+
70 50
|
124 |
+
70 64
|
125 |
+
71 72
|
126 |
+
74 29
|
127 |
+
74 75
|
128 |
+
74 215
|
129 |
+
75 74
|
130 |
+
75 215
|
131 |
+
76 58
|
132 |
+
76 104
|
133 |
+
77 103
|
134 |
+
78 64
|
135 |
+
78 68
|
136 |
+
80 207
|
137 |
+
80 210
|
138 |
+
82 8
|
139 |
+
82 77
|
140 |
+
82 83
|
141 |
+
82 97
|
142 |
+
82 163
|
143 |
+
83 82
|
144 |
+
83 226
|
145 |
+
83 243
|
146 |
+
84 29
|
147 |
+
84 154
|
148 |
+
87 101
|
149 |
+
87 189
|
150 |
+
89 90
|
151 |
+
90 89
|
152 |
+
90 94
|
153 |
+
91 86
|
154 |
+
92 19
|
155 |
+
92 30
|
156 |
+
92 106
|
157 |
+
94 72
|
158 |
+
94 89
|
159 |
+
94 90
|
160 |
+
95 30
|
161 |
+
96 75
|
162 |
+
96 256
|
163 |
+
97 80
|
164 |
+
97 128
|
165 |
+
98 86
|
166 |
+
100 86
|
167 |
+
101 87
|
168 |
+
103 77
|
169 |
+
103 104
|
170 |
+
104 58
|
171 |
+
104 77
|
172 |
+
104 103
|
173 |
+
106 22
|
174 |
+
107 38
|
175 |
+
107 114
|
176 |
+
107 122
|
177 |
+
108 49
|
178 |
+
108 55
|
179 |
+
111 121
|
180 |
+
111 128
|
181 |
+
111 210
|
182 |
+
113 253
|
183 |
+
114 107
|
184 |
+
116 30
|
185 |
+
116 140
|
186 |
+
118 129
|
187 |
+
118 138
|
188 |
+
120 88
|
189 |
+
121 128
|
190 |
+
122 31
|
191 |
+
123 32
|
192 |
+
124 244
|
193 |
+
125 132
|
194 |
+
126 163
|
195 |
+
126 180
|
196 |
+
128 38
|
197 |
+
128 111
|
198 |
+
129 118
|
199 |
+
132 29
|
200 |
+
132 30
|
201 |
+
133 30
|
202 |
+
134 135
|
203 |
+
134 150
|
204 |
+
135 134
|
205 |
+
137 144
|
206 |
+
138 118
|
207 |
+
138 129
|
208 |
+
139 142
|
209 |
+
141 157
|
210 |
+
141 163
|
211 |
+
142 139
|
212 |
+
143 2
|
213 |
+
144 137
|
214 |
+
145 151
|
215 |
+
146 137
|
216 |
+
146 165
|
217 |
+
146 169
|
218 |
+
146 171
|
219 |
+
147 31
|
220 |
+
147 128
|
221 |
+
148 146
|
222 |
+
148 169
|
223 |
+
148 171
|
224 |
+
148 282
|
225 |
+
149 128
|
226 |
+
149 148
|
227 |
+
149 172
|
228 |
+
150 86
|
229 |
+
151 145
|
230 |
+
152 4
|
231 |
+
153 134
|
232 |
+
154 155
|
233 |
+
156 161
|
234 |
+
157 141
|
235 |
+
161 156
|
236 |
+
165 144
|
237 |
+
165 148
|
238 |
+
167 149
|
239 |
+
169 15
|
240 |
+
169 148
|
241 |
+
169 171
|
242 |
+
170 115
|
243 |
+
170 173
|
244 |
+
170 183
|
245 |
+
170 202
|
246 |
+
171 72
|
247 |
+
171 148
|
248 |
+
171 169
|
249 |
+
173 170
|
250 |
+
175 100
|
251 |
+
176 10
|
252 |
+
178 181
|
253 |
+
181 178
|
254 |
+
182 38
|
255 |
+
182 171
|
256 |
+
183 96
|
257 |
+
185 50
|
258 |
+
186 127
|
259 |
+
187 50
|
260 |
+
187 65
|
261 |
+
188 30
|
262 |
+
188 50
|
263 |
+
189 87
|
264 |
+
189 89
|
265 |
+
190 35
|
266 |
+
190 38
|
267 |
+
190 122
|
268 |
+
190 182
|
269 |
+
191 54
|
270 |
+
191 118
|
271 |
+
191 129
|
272 |
+
191 172
|
273 |
+
192 149
|
274 |
+
192 167
|
275 |
+
195 75
|
276 |
+
197 50
|
277 |
+
197 188
|
278 |
+
198 218
|
279 |
+
198 221
|
280 |
+
198 222
|
281 |
+
200 65
|
282 |
+
200 220
|
283 |
+
201 113
|
284 |
+
202 156
|
285 |
+
203 232
|
286 |
+
204 194
|
287 |
+
207 38
|
288 |
+
207 122
|
289 |
+
207 124
|
290 |
+
208 30
|
291 |
+
208 50
|
292 |
+
210 38
|
293 |
+
210 207
|
294 |
+
211 37
|
295 |
+
213 35
|
296 |
+
213 38
|
297 |
+
214 13
|
298 |
+
214 14
|
299 |
+
214 171
|
300 |
+
214 213
|
301 |
+
215 75
|
302 |
+
217 39
|
303 |
+
218 68
|
304 |
+
218 222
|
305 |
+
221 198
|
306 |
+
222 198
|
307 |
+
222 218
|
308 |
+
223 39
|
309 |
+
225 3
|
310 |
+
226 22
|
311 |
+
229 65
|
312 |
+
230 68
|
313 |
+
231 43
|
314 |
+
232 95
|
315 |
+
232 203
|
316 |
+
233 99
|
317 |
+
234 68
|
318 |
+
234 230
|
319 |
+
237 244
|
320 |
+
238 145
|
321 |
+
242 3
|
322 |
+
242 113
|
323 |
+
244 237
|
324 |
+
249 96
|
325 |
+
250 156
|
326 |
+
252 65
|
327 |
+
254 65
|
328 |
+
258 113
|
329 |
+
268 4
|
330 |
+
270 183
|
331 |
+
272 6
|
332 |
+
275 96
|
333 |
+
280 183
|
334 |
+
280 206
|
335 |
+
282 37
|
336 |
+
285 75
|
337 |
+
290 285
|
338 |
+
293 290
|
.venv/share/doc/networkx-3.1/examples/algorithms/plot_beam_search.py
ADDED
@@ -0,0 +1,112 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"""
|
2 |
+
===========
|
3 |
+
Beam Search
|
4 |
+
===========
|
5 |
+
|
6 |
+
Beam search with dynamic beam width.
|
7 |
+
|
8 |
+
The progressive widening beam search repeatedly executes a beam search
|
9 |
+
with increasing beam width until the target node is found.
|
10 |
+
"""
|
11 |
+
import math
|
12 |
+
|
13 |
+
import matplotlib.pyplot as plt
|
14 |
+
import networkx as nx
|
15 |
+
|
16 |
+
|
17 |
+
def progressive_widening_search(G, source, value, condition, initial_width=1):
|
18 |
+
"""Progressive widening beam search to find a node.
|
19 |
+
|
20 |
+
The progressive widening beam search involves a repeated beam
|
21 |
+
search, starting with a small beam width then extending to
|
22 |
+
progressively larger beam widths if the target node is not
|
23 |
+
found. This implementation simply returns the first node found that
|
24 |
+
matches the termination condition.
|
25 |
+
|
26 |
+
`G` is a NetworkX graph.
|
27 |
+
|
28 |
+
`source` is a node in the graph. The search for the node of interest
|
29 |
+
begins here and extends only to those nodes in the (weakly)
|
30 |
+
connected component of this node.
|
31 |
+
|
32 |
+
`value` is a function that returns a real number indicating how good
|
33 |
+
a potential neighbor node is when deciding which neighbor nodes to
|
34 |
+
enqueue in the breadth-first search. Only the best nodes within the
|
35 |
+
current beam width will be enqueued at each step.
|
36 |
+
|
37 |
+
`condition` is the termination condition for the search. This is a
|
38 |
+
function that takes a node as input and return a Boolean indicating
|
39 |
+
whether the node is the target. If no node matches the termination
|
40 |
+
condition, this function raises :exc:`NodeNotFound`.
|
41 |
+
|
42 |
+
`initial_width` is the starting beam width for the beam search (the
|
43 |
+
default is one). If no node matching the `condition` is found with
|
44 |
+
this beam width, the beam search is restarted from the `source` node
|
45 |
+
with a beam width that is twice as large (so the beam width
|
46 |
+
increases exponentially). The search terminates after the beam width
|
47 |
+
exceeds the number of nodes in the graph.
|
48 |
+
|
49 |
+
"""
|
50 |
+
# Check for the special case in which the source node satisfies the
|
51 |
+
# termination condition.
|
52 |
+
if condition(source):
|
53 |
+
return source
|
54 |
+
# The largest possible value of `i` in this range yields a width at
|
55 |
+
# least the number of nodes in the graph, so the final invocation of
|
56 |
+
# `bfs_beam_edges` is equivalent to a plain old breadth-first
|
57 |
+
# search. Therefore, all nodes will eventually be visited.
|
58 |
+
log_m = math.ceil(math.log2(len(G)))
|
59 |
+
for i in range(log_m):
|
60 |
+
width = initial_width * pow(2, i)
|
61 |
+
# Since we are always starting from the same source node, this
|
62 |
+
# search may visit the same nodes many times (depending on the
|
63 |
+
# implementation of the `value` function).
|
64 |
+
for u, v in nx.bfs_beam_edges(G, source, value, width):
|
65 |
+
if condition(v):
|
66 |
+
return v
|
67 |
+
# At this point, since all nodes have been visited, we know that
|
68 |
+
# none of the nodes satisfied the termination condition.
|
69 |
+
raise nx.NodeNotFound("no node satisfied the termination condition")
|
70 |
+
|
71 |
+
|
72 |
+
###############################################################################
|
73 |
+
# Search for a node with high centrality.
|
74 |
+
# ---------------------------------------
|
75 |
+
#
|
76 |
+
# We generate a random graph, compute the centrality of each node, then perform
|
77 |
+
# the progressive widening search in order to find a node of high centrality.
|
78 |
+
|
79 |
+
# Set a seed for random number generation so the example is reproducible
|
80 |
+
seed = 89
|
81 |
+
|
82 |
+
G = nx.gnp_random_graph(100, 0.5, seed=seed)
|
83 |
+
centrality = nx.eigenvector_centrality(G)
|
84 |
+
avg_centrality = sum(centrality.values()) / len(G)
|
85 |
+
|
86 |
+
|
87 |
+
def has_high_centrality(v):
|
88 |
+
return centrality[v] >= avg_centrality
|
89 |
+
|
90 |
+
|
91 |
+
source = 0
|
92 |
+
value = centrality.get
|
93 |
+
condition = has_high_centrality
|
94 |
+
|
95 |
+
found_node = progressive_widening_search(G, source, value, condition)
|
96 |
+
c = centrality[found_node]
|
97 |
+
print(f"found node {found_node} with centrality {c}")
|
98 |
+
|
99 |
+
|
100 |
+
# Draw graph
|
101 |
+
pos = nx.spring_layout(G, seed=seed)
|
102 |
+
options = {
|
103 |
+
"node_color": "blue",
|
104 |
+
"node_size": 20,
|
105 |
+
"edge_color": "grey",
|
106 |
+
"linewidths": 0,
|
107 |
+
"width": 0.1,
|
108 |
+
}
|
109 |
+
nx.draw(G, pos, **options)
|
110 |
+
# Draw node with high centrality as large and red
|
111 |
+
nx.draw_networkx_nodes(G, pos, nodelist=[found_node], node_size=100, node_color="r")
|
112 |
+
plt.show()
|
.venv/share/doc/networkx-3.1/examples/algorithms/plot_betweenness_centrality.py
ADDED
@@ -0,0 +1,83 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"""
|
2 |
+
======================
|
3 |
+
Betweenness Centrality
|
4 |
+
======================
|
5 |
+
|
6 |
+
Betweenness centrality measures of positive gene functional associations
|
7 |
+
using WormNet v.3-GS.
|
8 |
+
|
9 |
+
Data from: https://www.inetbio.org/wormnet/downloadnetwork.php
|
10 |
+
"""
|
11 |
+
|
12 |
+
from random import sample
|
13 |
+
import networkx as nx
|
14 |
+
import matplotlib.pyplot as plt
|
15 |
+
|
16 |
+
# Gold standard data of positive gene functional associations
|
17 |
+
# from https://www.inetbio.org/wormnet/downloadnetwork.php
|
18 |
+
G = nx.read_edgelist("WormNet.v3.benchmark.txt")
|
19 |
+
|
20 |
+
# remove randomly selected nodes (to make example fast)
|
21 |
+
num_to_remove = int(len(G) / 1.5)
|
22 |
+
nodes = sample(list(G.nodes), num_to_remove)
|
23 |
+
G.remove_nodes_from(nodes)
|
24 |
+
|
25 |
+
# remove low-degree nodes
|
26 |
+
low_degree = [n for n, d in G.degree() if d < 10]
|
27 |
+
G.remove_nodes_from(low_degree)
|
28 |
+
|
29 |
+
# largest connected component
|
30 |
+
components = nx.connected_components(G)
|
31 |
+
largest_component = max(components, key=len)
|
32 |
+
H = G.subgraph(largest_component)
|
33 |
+
|
34 |
+
# compute centrality
|
35 |
+
centrality = nx.betweenness_centrality(H, k=10, endpoints=True)
|
36 |
+
|
37 |
+
# compute community structure
|
38 |
+
lpc = nx.community.label_propagation_communities(H)
|
39 |
+
community_index = {n: i for i, com in enumerate(lpc) for n in com}
|
40 |
+
|
41 |
+
#### draw graph ####
|
42 |
+
fig, ax = plt.subplots(figsize=(20, 15))
|
43 |
+
pos = nx.spring_layout(H, k=0.15, seed=4572321)
|
44 |
+
node_color = [community_index[n] for n in H]
|
45 |
+
node_size = [v * 20000 for v in centrality.values()]
|
46 |
+
nx.draw_networkx(
|
47 |
+
H,
|
48 |
+
pos=pos,
|
49 |
+
with_labels=False,
|
50 |
+
node_color=node_color,
|
51 |
+
node_size=node_size,
|
52 |
+
edge_color="gainsboro",
|
53 |
+
alpha=0.4,
|
54 |
+
)
|
55 |
+
|
56 |
+
# Title/legend
|
57 |
+
font = {"color": "k", "fontweight": "bold", "fontsize": 20}
|
58 |
+
ax.set_title("Gene functional association network (C. elegans)", font)
|
59 |
+
# Change font color for legend
|
60 |
+
font["color"] = "r"
|
61 |
+
|
62 |
+
ax.text(
|
63 |
+
0.80,
|
64 |
+
0.10,
|
65 |
+
"node color = community structure",
|
66 |
+
horizontalalignment="center",
|
67 |
+
transform=ax.transAxes,
|
68 |
+
fontdict=font,
|
69 |
+
)
|
70 |
+
ax.text(
|
71 |
+
0.80,
|
72 |
+
0.06,
|
73 |
+
"node size = betweenness centrality",
|
74 |
+
horizontalalignment="center",
|
75 |
+
transform=ax.transAxes,
|
76 |
+
fontdict=font,
|
77 |
+
)
|
78 |
+
|
79 |
+
# Resize figure for label readability
|
80 |
+
ax.margins(0.1, 0.05)
|
81 |
+
fig.tight_layout()
|
82 |
+
plt.axis("off")
|
83 |
+
plt.show()
|
.venv/share/doc/networkx-3.1/examples/algorithms/plot_blockmodel.py
ADDED
@@ -0,0 +1,79 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"""
|
2 |
+
==========
|
3 |
+
Blockmodel
|
4 |
+
==========
|
5 |
+
|
6 |
+
Example of creating a block model using the quotient_graph function in NX. Data
|
7 |
+
used is the Hartford, CT drug users network::
|
8 |
+
|
9 |
+
@article{weeks2002social,
|
10 |
+
title={Social networks of drug users in high-risk sites: Finding the connections},
|
11 |
+
url = {https://doi.org/10.1023/A:1015457400897},
|
12 |
+
doi = {10.1023/A:1015457400897},
|
13 |
+
author={Weeks, Margaret R and Clair, Scott and Borgatti, Stephen P and Radda, Kim and Schensul, Jean J},
|
14 |
+
journal={{AIDS and Behavior}},
|
15 |
+
volume={6},
|
16 |
+
number={2},
|
17 |
+
pages={193--206},
|
18 |
+
year={2002},
|
19 |
+
publisher={Springer}
|
20 |
+
}
|
21 |
+
|
22 |
+
"""
|
23 |
+
|
24 |
+
from collections import defaultdict
|
25 |
+
|
26 |
+
import matplotlib.pyplot as plt
|
27 |
+
import networkx as nx
|
28 |
+
import numpy as np
|
29 |
+
from scipy.cluster import hierarchy
|
30 |
+
from scipy.spatial import distance
|
31 |
+
|
32 |
+
|
33 |
+
def create_hc(G):
|
34 |
+
"""Creates hierarchical cluster of graph G from distance matrix"""
|
35 |
+
path_length = nx.all_pairs_shortest_path_length(G)
|
36 |
+
distances = np.zeros((len(G), len(G)))
|
37 |
+
for u, p in path_length:
|
38 |
+
for v, d in p.items():
|
39 |
+
distances[u][v] = d
|
40 |
+
# Create hierarchical cluster
|
41 |
+
Y = distance.squareform(distances)
|
42 |
+
Z = hierarchy.complete(Y) # Creates HC using farthest point linkage
|
43 |
+
# This partition selection is arbitrary, for illustrive purposes
|
44 |
+
membership = list(hierarchy.fcluster(Z, t=1.15))
|
45 |
+
# Create collection of lists for blockmodel
|
46 |
+
partition = defaultdict(list)
|
47 |
+
for n, p in zip(list(range(len(G))), membership):
|
48 |
+
partition[p].append(n)
|
49 |
+
return list(partition.values())
|
50 |
+
|
51 |
+
|
52 |
+
G = nx.read_edgelist("hartford_drug.edgelist")
|
53 |
+
|
54 |
+
# Extract largest connected component into graph H
|
55 |
+
H = G.subgraph(next(nx.connected_components(G)))
|
56 |
+
# Makes life easier to have consecutively labeled integer nodes
|
57 |
+
H = nx.convert_node_labels_to_integers(H)
|
58 |
+
# Create partitions with hierarchical clustering
|
59 |
+
partitions = create_hc(H)
|
60 |
+
# Build blockmodel graph
|
61 |
+
BM = nx.quotient_graph(H, partitions, relabel=True)
|
62 |
+
|
63 |
+
# Draw original graph
|
64 |
+
pos = nx.spring_layout(H, iterations=100, seed=83) # Seed for reproducibility
|
65 |
+
plt.subplot(211)
|
66 |
+
nx.draw(H, pos, with_labels=False, node_size=10)
|
67 |
+
|
68 |
+
# Draw block model with weighted edges and nodes sized by number of internal nodes
|
69 |
+
node_size = [BM.nodes[x]["nnodes"] * 10 for x in BM.nodes()]
|
70 |
+
edge_width = [(2 * d["weight"]) for (u, v, d) in BM.edges(data=True)]
|
71 |
+
# Set positions to mean of positions of internal nodes from original graph
|
72 |
+
posBM = {}
|
73 |
+
for n in BM:
|
74 |
+
xy = np.array([pos[u] for u in BM.nodes[n]["graph"]])
|
75 |
+
posBM[n] = xy.mean(axis=0)
|
76 |
+
plt.subplot(212)
|
77 |
+
nx.draw(BM, posBM, node_size=node_size, width=edge_width, with_labels=False)
|
78 |
+
plt.axis("off")
|
79 |
+
plt.show()
|
.venv/share/doc/networkx-3.1/examples/algorithms/plot_circuits.py
ADDED
@@ -0,0 +1,103 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"""
|
2 |
+
========
|
3 |
+
Circuits
|
4 |
+
========
|
5 |
+
|
6 |
+
Convert a Boolean circuit to an equivalent Boolean formula.
|
7 |
+
|
8 |
+
A Boolean circuit can be exponentially more expressive than an
|
9 |
+
equivalent formula in the worst case, since the circuit can reuse
|
10 |
+
subcircuits multiple times, whereas a formula cannot reuse subformulas
|
11 |
+
more than once. Thus creating a Boolean formula from a Boolean circuit
|
12 |
+
in this way may be infeasible if the circuit is large.
|
13 |
+
|
14 |
+
"""
|
15 |
+
import matplotlib.pyplot as plt
|
16 |
+
import networkx as nx
|
17 |
+
|
18 |
+
|
19 |
+
def circuit_to_formula(circuit):
|
20 |
+
# Convert the circuit to an equivalent formula.
|
21 |
+
formula = nx.dag_to_branching(circuit)
|
22 |
+
# Transfer the operator or variable labels for each node from the
|
23 |
+
# circuit to the formula.
|
24 |
+
for v in formula:
|
25 |
+
source = formula.nodes[v]["source"]
|
26 |
+
formula.nodes[v]["label"] = circuit.nodes[source]["label"]
|
27 |
+
return formula
|
28 |
+
|
29 |
+
|
30 |
+
def formula_to_string(formula):
|
31 |
+
def _to_string(formula, root):
|
32 |
+
# If there are no children, this is a variable node.
|
33 |
+
label = formula.nodes[root]["label"]
|
34 |
+
if not formula[root]:
|
35 |
+
return label
|
36 |
+
# Otherwise, this is an operator.
|
37 |
+
children = formula[root]
|
38 |
+
# If one child, the label must be a NOT operator.
|
39 |
+
if len(children) == 1:
|
40 |
+
child = nx.utils.arbitrary_element(children)
|
41 |
+
return f"{label}({_to_string(formula, child)})"
|
42 |
+
# NB "left" and "right" here are a little misleading: there is
|
43 |
+
# no order on the children of a node. That's okay because the
|
44 |
+
# Boolean AND and OR operators are symmetric. It just means that
|
45 |
+
# the order of the operands cannot be predicted and hence the
|
46 |
+
# function does not necessarily behave the same way on every
|
47 |
+
# invocation.
|
48 |
+
left, right = formula[root]
|
49 |
+
left_subformula = _to_string(formula, left)
|
50 |
+
right_subformula = _to_string(formula, right)
|
51 |
+
return f"({left_subformula} {label} {right_subformula})"
|
52 |
+
|
53 |
+
root = next(v for v, d in formula.in_degree() if d == 0)
|
54 |
+
return _to_string(formula, root)
|
55 |
+
|
56 |
+
|
57 |
+
###############################################################################
|
58 |
+
# Create an example Boolean circuit.
|
59 |
+
# ----------------------------------
|
60 |
+
#
|
61 |
+
# This circuit has a ∧ at the output and two ∨s at the next layer.
|
62 |
+
# The third layer has a variable x that appears in the left ∨, a
|
63 |
+
# variable y that appears in both the left and right ∨s, and a
|
64 |
+
# negation for the variable z that appears as the sole node in the
|
65 |
+
# fourth layer.
|
66 |
+
circuit = nx.DiGraph()
|
67 |
+
# Layer 0
|
68 |
+
circuit.add_node(0, label="∧", layer=0)
|
69 |
+
# Layer 1
|
70 |
+
circuit.add_node(1, label="∨", layer=1)
|
71 |
+
circuit.add_node(2, label="∨", layer=1)
|
72 |
+
circuit.add_edge(0, 1)
|
73 |
+
circuit.add_edge(0, 2)
|
74 |
+
# Layer 2
|
75 |
+
circuit.add_node(3, label="x", layer=2)
|
76 |
+
circuit.add_node(4, label="y", layer=2)
|
77 |
+
circuit.add_node(5, label="¬", layer=2)
|
78 |
+
circuit.add_edge(1, 3)
|
79 |
+
circuit.add_edge(1, 4)
|
80 |
+
circuit.add_edge(2, 4)
|
81 |
+
circuit.add_edge(2, 5)
|
82 |
+
# Layer 3
|
83 |
+
circuit.add_node(6, label="z", layer=3)
|
84 |
+
circuit.add_edge(5, 6)
|
85 |
+
# Convert the circuit to an equivalent formula.
|
86 |
+
formula = circuit_to_formula(circuit)
|
87 |
+
print(formula_to_string(formula))
|
88 |
+
|
89 |
+
|
90 |
+
labels = nx.get_node_attributes(circuit, "label")
|
91 |
+
options = {
|
92 |
+
"node_size": 600,
|
93 |
+
"alpha": 0.5,
|
94 |
+
"node_color": "blue",
|
95 |
+
"labels": labels,
|
96 |
+
"font_size": 22,
|
97 |
+
}
|
98 |
+
plt.figure(figsize=(8, 8))
|
99 |
+
pos = nx.multipartite_layout(circuit, subset_key="layer")
|
100 |
+
nx.draw_networkx(circuit, pos, **options)
|
101 |
+
plt.title(formula_to_string(formula))
|
102 |
+
plt.axis("equal")
|
103 |
+
plt.show()
|
.venv/share/doc/networkx-3.1/examples/algorithms/plot_davis_club.py
ADDED
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"""
|
2 |
+
==========
|
3 |
+
Davis Club
|
4 |
+
==========
|
5 |
+
|
6 |
+
Davis Southern Club Women
|
7 |
+
|
8 |
+
Shows how to make unipartite projections of the graph and compute the
|
9 |
+
properties of those graphs.
|
10 |
+
|
11 |
+
These data were collected by Davis et al. in the 1930s.
|
12 |
+
They represent observed attendance at 14 social events by 18 Southern women.
|
13 |
+
The graph is bipartite (clubs, women).
|
14 |
+
"""
|
15 |
+
import matplotlib.pyplot as plt
|
16 |
+
import networkx as nx
|
17 |
+
from networkx.algorithms import bipartite
|
18 |
+
|
19 |
+
G = nx.davis_southern_women_graph()
|
20 |
+
women = G.graph["top"]
|
21 |
+
clubs = G.graph["bottom"]
|
22 |
+
|
23 |
+
print("Biadjacency matrix")
|
24 |
+
print(bipartite.biadjacency_matrix(G, women, clubs))
|
25 |
+
|
26 |
+
# project bipartite graph onto women nodes
|
27 |
+
W = bipartite.projected_graph(G, women)
|
28 |
+
print()
|
29 |
+
print("#Friends, Member")
|
30 |
+
for w in women:
|
31 |
+
print(f"{W.degree(w)} {w}")
|
32 |
+
|
33 |
+
# project bipartite graph onto women nodes keeping number of co-occurrence
|
34 |
+
# the degree computed is weighted and counts the total number of shared contacts
|
35 |
+
W = bipartite.weighted_projected_graph(G, women)
|
36 |
+
print()
|
37 |
+
print("#Friend meetings, Member")
|
38 |
+
for w in women:
|
39 |
+
print(f"{W.degree(w, weight='weight')} {w}")
|
40 |
+
|
41 |
+
pos = nx.spring_layout(G, seed=648) # Seed layout for reproducible node positions
|
42 |
+
nx.draw(G, pos)
|
43 |
+
plt.show()
|
.venv/share/doc/networkx-3.1/examples/algorithms/plot_dedensification.py
ADDED
@@ -0,0 +1,92 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"""
|
2 |
+
===============
|
3 |
+
Dedensification
|
4 |
+
===============
|
5 |
+
|
6 |
+
Examples of dedensification of a graph. Dedensification retains the structural
|
7 |
+
pattern of the original graph and will only add compressor nodes when doing so
|
8 |
+
would result in fewer edges in the compressed graph.
|
9 |
+
"""
|
10 |
+
import matplotlib.pyplot as plt
|
11 |
+
import networkx as nx
|
12 |
+
|
13 |
+
plt.suptitle("Dedensification")
|
14 |
+
|
15 |
+
original_graph = nx.DiGraph()
|
16 |
+
white_nodes = ["1", "2", "3", "4", "5", "6"]
|
17 |
+
red_nodes = ["A", "B", "C"]
|
18 |
+
node_sizes = [250 for node in white_nodes + red_nodes]
|
19 |
+
node_colors = ["white" for n in white_nodes] + ["red" for n in red_nodes]
|
20 |
+
|
21 |
+
original_graph.add_nodes_from(white_nodes + red_nodes)
|
22 |
+
original_graph.add_edges_from(
|
23 |
+
[
|
24 |
+
("1", "C"),
|
25 |
+
("1", "B"),
|
26 |
+
("2", "C"),
|
27 |
+
("2", "B"),
|
28 |
+
("2", "A"),
|
29 |
+
("3", "B"),
|
30 |
+
("3", "A"),
|
31 |
+
("3", "6"),
|
32 |
+
("4", "C"),
|
33 |
+
("4", "B"),
|
34 |
+
("4", "A"),
|
35 |
+
("5", "B"),
|
36 |
+
("5", "A"),
|
37 |
+
("6", "5"),
|
38 |
+
("A", "6"),
|
39 |
+
]
|
40 |
+
)
|
41 |
+
base_options = {"with_labels": True, "edgecolors": "black"}
|
42 |
+
pos = {
|
43 |
+
"3": (0, 1),
|
44 |
+
"2": (0, 2),
|
45 |
+
"1": (0, 3),
|
46 |
+
"6": (1, 0),
|
47 |
+
"A": (1, 1),
|
48 |
+
"B": (1, 2),
|
49 |
+
"C": (1, 3),
|
50 |
+
"4": (2, 3),
|
51 |
+
"5": (2, 1),
|
52 |
+
}
|
53 |
+
ax1 = plt.subplot(1, 2, 1)
|
54 |
+
plt.title("Original (%s edges)" % original_graph.number_of_edges())
|
55 |
+
nx.draw_networkx(original_graph, pos=pos, node_color=node_colors, **base_options)
|
56 |
+
|
57 |
+
nonexp_graph, compression_nodes = nx.summarization.dedensify(
|
58 |
+
original_graph, threshold=2, copy=False
|
59 |
+
)
|
60 |
+
nonexp_node_colors = list(node_colors)
|
61 |
+
nonexp_node_sizes = list(node_sizes)
|
62 |
+
for node in compression_nodes:
|
63 |
+
nonexp_node_colors.append("yellow")
|
64 |
+
nonexp_node_sizes.append(600)
|
65 |
+
plt.subplot(1, 2, 2)
|
66 |
+
|
67 |
+
plt.title("Dedensified (%s edges)" % nonexp_graph.number_of_edges())
|
68 |
+
nonexp_pos = {
|
69 |
+
"5": (0, 0),
|
70 |
+
"B": (0, 2),
|
71 |
+
"1": (0, 3),
|
72 |
+
"6": (1, 0.75),
|
73 |
+
"3": (1.5, 1.5),
|
74 |
+
"A": (2, 0),
|
75 |
+
"C": (2, 3),
|
76 |
+
"4": (3, 1.5),
|
77 |
+
"2": (3, 2.5),
|
78 |
+
}
|
79 |
+
c_nodes = list(compression_nodes)
|
80 |
+
c_nodes.sort()
|
81 |
+
for spot, node in enumerate(c_nodes):
|
82 |
+
nonexp_pos[node] = (2, spot + 2)
|
83 |
+
nx.draw_networkx(
|
84 |
+
nonexp_graph,
|
85 |
+
pos=nonexp_pos,
|
86 |
+
node_color=nonexp_node_colors,
|
87 |
+
node_size=nonexp_node_sizes,
|
88 |
+
**base_options,
|
89 |
+
)
|
90 |
+
|
91 |
+
plt.tight_layout()
|
92 |
+
plt.show()
|
.venv/share/doc/networkx-3.1/examples/algorithms/plot_girvan_newman.py
ADDED
@@ -0,0 +1,79 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"""
|
2 |
+
=======================================
|
3 |
+
Community Detection using Girvan-Newman
|
4 |
+
=======================================
|
5 |
+
|
6 |
+
This example shows the detection of communities in the Zachary Karate
|
7 |
+
Club dataset using the Girvan-Newman method.
|
8 |
+
|
9 |
+
We plot the change in modularity as important edges are removed.
|
10 |
+
Graph is coloured and plotted based on community detection when number
|
11 |
+
of iterations are 1 and 4 respectively.
|
12 |
+
"""
|
13 |
+
|
14 |
+
import networkx as nx
|
15 |
+
import pandas as pd
|
16 |
+
import matplotlib.pyplot as plt
|
17 |
+
|
18 |
+
# Load karate graph and find communities using Girvan-Newman
|
19 |
+
G = nx.karate_club_graph()
|
20 |
+
communities = list(nx.community.girvan_newman(G))
|
21 |
+
|
22 |
+
# Modularity -> measures the strength of division of a network into modules
|
23 |
+
modularity_df = pd.DataFrame(
|
24 |
+
[
|
25 |
+
[k + 1, nx.community.modularity(G, communities[k])]
|
26 |
+
for k in range(len(communities))
|
27 |
+
],
|
28 |
+
columns=["k", "modularity"],
|
29 |
+
)
|
30 |
+
|
31 |
+
|
32 |
+
# function to create node colour list
|
33 |
+
def create_community_node_colors(graph, communities):
|
34 |
+
number_of_colors = len(communities[0])
|
35 |
+
colors = ["#D4FCB1", "#CDC5FC", "#FFC2C4", "#F2D140", "#BCC6C8"][:number_of_colors]
|
36 |
+
node_colors = []
|
37 |
+
for node in graph:
|
38 |
+
current_community_index = 0
|
39 |
+
for community in communities:
|
40 |
+
if node in community:
|
41 |
+
node_colors.append(colors[current_community_index])
|
42 |
+
break
|
43 |
+
current_community_index += 1
|
44 |
+
return node_colors
|
45 |
+
|
46 |
+
|
47 |
+
# function to plot graph with node colouring based on communities
|
48 |
+
def visualize_communities(graph, communities, i):
|
49 |
+
node_colors = create_community_node_colors(graph, communities)
|
50 |
+
modularity = round(nx.community.modularity(graph, communities), 6)
|
51 |
+
title = f"Community Visualization of {len(communities)} communities with modularity of {modularity}"
|
52 |
+
pos = nx.spring_layout(graph, k=0.3, iterations=50, seed=2)
|
53 |
+
plt.subplot(3, 1, i)
|
54 |
+
plt.title(title)
|
55 |
+
nx.draw(
|
56 |
+
graph,
|
57 |
+
pos=pos,
|
58 |
+
node_size=1000,
|
59 |
+
node_color=node_colors,
|
60 |
+
with_labels=True,
|
61 |
+
font_size=20,
|
62 |
+
font_color="black",
|
63 |
+
)
|
64 |
+
|
65 |
+
|
66 |
+
fig, ax = plt.subplots(3, figsize=(15, 20))
|
67 |
+
|
68 |
+
# Plot graph with colouring based on communities
|
69 |
+
visualize_communities(G, communities[0], 1)
|
70 |
+
visualize_communities(G, communities[3], 2)
|
71 |
+
|
72 |
+
# Plot change in modularity as the important edges are removed
|
73 |
+
modularity_df.plot.bar(
|
74 |
+
x="k",
|
75 |
+
ax=ax[2],
|
76 |
+
color="#F2D140",
|
77 |
+
title="Modularity Trend for Girvan-Newman Community Detection",
|
78 |
+
)
|
79 |
+
plt.show()
|
.venv/share/doc/networkx-3.1/examples/algorithms/plot_iterated_dynamical_systems.py
ADDED
@@ -0,0 +1,210 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"""
|
2 |
+
==========================
|
3 |
+
Iterated Dynamical Systems
|
4 |
+
==========================
|
5 |
+
|
6 |
+
Digraphs from Integer-valued Iterated Functions
|
7 |
+
|
8 |
+
Sums of cubes on 3N
|
9 |
+
-------------------
|
10 |
+
|
11 |
+
The number 153 has a curious property.
|
12 |
+
|
13 |
+
Let 3N={3,6,9,12,...} be the set of positive multiples of 3. Define an
|
14 |
+
iterative process f:3N->3N as follows: for a given n, take each digit
|
15 |
+
of n (in base 10), cube it and then sum the cubes to obtain f(n).
|
16 |
+
|
17 |
+
When this process is repeated, the resulting series n, f(n), f(f(n)),...
|
18 |
+
terminate in 153 after a finite number of iterations (the process ends
|
19 |
+
because 153 = 1**3 + 5**3 + 3**3).
|
20 |
+
|
21 |
+
In the language of discrete dynamical systems, 153 is the global
|
22 |
+
attractor for the iterated map f restricted to the set 3N.
|
23 |
+
|
24 |
+
For example: take the number 108
|
25 |
+
|
26 |
+
f(108) = 1**3 + 0**3 + 8**3 = 513
|
27 |
+
|
28 |
+
and
|
29 |
+
|
30 |
+
f(513) = 5**3 + 1**3 + 3**3 = 153
|
31 |
+
|
32 |
+
So, starting at 108 we reach 153 in two iterations,
|
33 |
+
represented as:
|
34 |
+
|
35 |
+
108->513->153
|
36 |
+
|
37 |
+
Computing all orbits of 3N up to 10**5 reveals that the attractor
|
38 |
+
153 is reached in a maximum of 14 iterations. In this code we
|
39 |
+
show that 13 cycles is the maximum required for all integers (in 3N)
|
40 |
+
less than 10,000.
|
41 |
+
|
42 |
+
The smallest number that requires 13 iterations to reach 153, is 177, i.e.,
|
43 |
+
|
44 |
+
177->687->1071->345->216->225->141->66->432->99->1458->702->351->153
|
45 |
+
|
46 |
+
The resulting large digraphs are useful for testing network software.
|
47 |
+
|
48 |
+
The general problem
|
49 |
+
-------------------
|
50 |
+
|
51 |
+
Given numbers n, a power p and base b, define F(n; p, b) as the sum of
|
52 |
+
the digits of n (in base b) raised to the power p. The above example
|
53 |
+
corresponds to f(n)=F(n; 3,10), and below F(n; p, b) is implemented as
|
54 |
+
the function powersum(n,p,b). The iterative dynamical system defined by
|
55 |
+
the mapping n:->f(n) above (over 3N) converges to a single fixed point;
|
56 |
+
153. Applying the map to all positive integers N, leads to a discrete
|
57 |
+
dynamical process with 5 fixed points: 1, 153, 370, 371, 407. Modulo 3
|
58 |
+
those numbers are 1, 0, 1, 2, 2. The function f above has the added
|
59 |
+
property that it maps a multiple of 3 to another multiple of 3; i.e. it
|
60 |
+
is invariant on the subset 3N.
|
61 |
+
|
62 |
+
|
63 |
+
The squaring of digits (in base 10) result in cycles and the
|
64 |
+
single fixed point 1. I.e., from a certain point on, the process
|
65 |
+
starts repeating itself.
|
66 |
+
|
67 |
+
keywords: "Recurring Digital Invariant", "Narcissistic Number",
|
68 |
+
"Happy Number"
|
69 |
+
|
70 |
+
The 3n+1 problem
|
71 |
+
----------------
|
72 |
+
|
73 |
+
There is a rich history of mathematical recreations
|
74 |
+
associated with discrete dynamical systems. The most famous
|
75 |
+
is the Collatz 3n+1 problem. See the function
|
76 |
+
collatz_problem_digraph below. The Collatz conjecture
|
77 |
+
--- that every orbit returns to the fixed point 1 in finite time
|
78 |
+
--- is still unproven. Even the great Paul Erdos said "Mathematics
|
79 |
+
is not yet ready for such problems", and offered $500
|
80 |
+
for its solution.
|
81 |
+
|
82 |
+
keywords: "3n+1", "3x+1", "Collatz problem", "Thwaite's conjecture"
|
83 |
+
"""
|
84 |
+
|
85 |
+
import networkx as nx
|
86 |
+
|
87 |
+
nmax = 10000
|
88 |
+
p = 3
|
89 |
+
|
90 |
+
|
91 |
+
def digitsrep(n, b=10):
|
92 |
+
"""Return list of digits comprising n represented in base b.
|
93 |
+
n must be a nonnegative integer"""
|
94 |
+
|
95 |
+
if n <= 0:
|
96 |
+
return [0]
|
97 |
+
|
98 |
+
dlist = []
|
99 |
+
while n > 0:
|
100 |
+
# Prepend next least-significant digit
|
101 |
+
dlist = [n % b] + dlist
|
102 |
+
# Floor-division
|
103 |
+
n = n // b
|
104 |
+
return dlist
|
105 |
+
|
106 |
+
|
107 |
+
def powersum(n, p, b=10):
|
108 |
+
"""Return sum of digits of n (in base b) raised to the power p."""
|
109 |
+
dlist = digitsrep(n, b)
|
110 |
+
sum = 0
|
111 |
+
for k in dlist:
|
112 |
+
sum += k**p
|
113 |
+
return sum
|
114 |
+
|
115 |
+
|
116 |
+
def attractor153_graph(n, p, multiple=3, b=10):
|
117 |
+
"""Return digraph of iterations of powersum(n,3,10)."""
|
118 |
+
G = nx.DiGraph()
|
119 |
+
for k in range(1, n + 1):
|
120 |
+
if k % multiple == 0 and k not in G:
|
121 |
+
k1 = k
|
122 |
+
knext = powersum(k1, p, b)
|
123 |
+
while k1 != knext:
|
124 |
+
G.add_edge(k1, knext)
|
125 |
+
k1 = knext
|
126 |
+
knext = powersum(k1, p, b)
|
127 |
+
return G
|
128 |
+
|
129 |
+
|
130 |
+
def squaring_cycle_graph_old(n, b=10):
|
131 |
+
"""Return digraph of iterations of powersum(n,2,10)."""
|
132 |
+
G = nx.DiGraph()
|
133 |
+
for k in range(1, n + 1):
|
134 |
+
k1 = k
|
135 |
+
G.add_node(k1) # case k1==knext, at least add node
|
136 |
+
knext = powersum(k1, 2, b)
|
137 |
+
G.add_edge(k1, knext)
|
138 |
+
while k1 != knext: # stop if fixed point
|
139 |
+
k1 = knext
|
140 |
+
knext = powersum(k1, 2, b)
|
141 |
+
G.add_edge(k1, knext)
|
142 |
+
if G.out_degree(knext) >= 1:
|
143 |
+
# knext has already been iterated in and out
|
144 |
+
break
|
145 |
+
return G
|
146 |
+
|
147 |
+
|
148 |
+
def sum_of_digits_graph(nmax, b=10):
|
149 |
+
def f(n):
|
150 |
+
return powersum(n, 1, b)
|
151 |
+
|
152 |
+
return discrete_dynamics_digraph(nmax, f)
|
153 |
+
|
154 |
+
|
155 |
+
def squaring_cycle_digraph(nmax, b=10):
|
156 |
+
def f(n):
|
157 |
+
return powersum(n, 2, b)
|
158 |
+
|
159 |
+
return discrete_dynamics_digraph(nmax, f)
|
160 |
+
|
161 |
+
|
162 |
+
def cubing_153_digraph(nmax):
|
163 |
+
def f(n):
|
164 |
+
return powersum(n, 3, 10)
|
165 |
+
|
166 |
+
return discrete_dynamics_digraph(nmax, f)
|
167 |
+
|
168 |
+
|
169 |
+
def discrete_dynamics_digraph(nmax, f, itermax=50000):
|
170 |
+
G = nx.DiGraph()
|
171 |
+
for k in range(1, nmax + 1):
|
172 |
+
kold = k
|
173 |
+
G.add_node(kold)
|
174 |
+
knew = f(kold)
|
175 |
+
G.add_edge(kold, knew)
|
176 |
+
while kold != knew and kold << itermax:
|
177 |
+
# iterate until fixed point reached or itermax is exceeded
|
178 |
+
kold = knew
|
179 |
+
knew = f(kold)
|
180 |
+
G.add_edge(kold, knew)
|
181 |
+
if G.out_degree(knew) >= 1:
|
182 |
+
# knew has already been iterated in and out
|
183 |
+
break
|
184 |
+
return G
|
185 |
+
|
186 |
+
|
187 |
+
def collatz_problem_digraph(nmax):
|
188 |
+
def f(n):
|
189 |
+
if n % 2 == 0:
|
190 |
+
return n // 2
|
191 |
+
else:
|
192 |
+
return 3 * n + 1
|
193 |
+
|
194 |
+
return discrete_dynamics_digraph(nmax, f)
|
195 |
+
|
196 |
+
|
197 |
+
def fixed_points(G):
|
198 |
+
"""Return a list of fixed points for the discrete dynamical
|
199 |
+
system represented by the digraph G.
|
200 |
+
"""
|
201 |
+
return [n for n in G if G.out_degree(n) == 0]
|
202 |
+
|
203 |
+
|
204 |
+
nmax = 10000
|
205 |
+
print(f"Building cubing_153_digraph({nmax})")
|
206 |
+
G = cubing_153_digraph(nmax)
|
207 |
+
print("Resulting digraph has", len(G), "nodes and", G.size(), " edges")
|
208 |
+
print("Shortest path from 177 to 153 is:")
|
209 |
+
print(nx.shortest_path(G, 177, 153))
|
210 |
+
print(f"fixed points are {fixed_points(G)}")
|
.venv/share/doc/networkx-3.1/examples/algorithms/plot_krackhardt_centrality.py
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"""
|
2 |
+
=====================
|
3 |
+
Krackhardt Centrality
|
4 |
+
=====================
|
5 |
+
|
6 |
+
Centrality measures of Krackhardt social network.
|
7 |
+
"""
|
8 |
+
|
9 |
+
import matplotlib.pyplot as plt
|
10 |
+
import networkx as nx
|
11 |
+
|
12 |
+
G = nx.krackhardt_kite_graph()
|
13 |
+
|
14 |
+
print("Betweenness")
|
15 |
+
b = nx.betweenness_centrality(G)
|
16 |
+
for v in G.nodes():
|
17 |
+
print(f"{v:2} {b[v]:.3f}")
|
18 |
+
|
19 |
+
print("Degree centrality")
|
20 |
+
d = nx.degree_centrality(G)
|
21 |
+
for v in G.nodes():
|
22 |
+
print(f"{v:2} {d[v]:.3f}")
|
23 |
+
|
24 |
+
print("Closeness centrality")
|
25 |
+
c = nx.closeness_centrality(G)
|
26 |
+
for v in G.nodes():
|
27 |
+
print(f"{v:2} {c[v]:.3f}")
|
28 |
+
|
29 |
+
pos = nx.spring_layout(G, seed=367) # Seed layout for reproducibility
|
30 |
+
nx.draw(G, pos)
|
31 |
+
plt.show()
|
.venv/share/doc/networkx-3.1/examples/algorithms/plot_maximum_independent_set.py
ADDED
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"""
|
2 |
+
=======================
|
3 |
+
Maximum Independent Set
|
4 |
+
=======================
|
5 |
+
|
6 |
+
An independent set is a set of vertices in a graph where no two vertices in the
|
7 |
+
set are adjacent. The maximum independent set is the independent set of largest
|
8 |
+
possible size for a given graph.
|
9 |
+
"""
|
10 |
+
|
11 |
+
import numpy as np
|
12 |
+
import matplotlib.pyplot as plt
|
13 |
+
import networkx as nx
|
14 |
+
from networkx.algorithms import approximation as approx
|
15 |
+
|
16 |
+
G = nx.Graph(
|
17 |
+
[
|
18 |
+
(1, 2),
|
19 |
+
(7, 2),
|
20 |
+
(3, 9),
|
21 |
+
(3, 2),
|
22 |
+
(7, 6),
|
23 |
+
(5, 2),
|
24 |
+
(1, 5),
|
25 |
+
(2, 8),
|
26 |
+
(10, 2),
|
27 |
+
(1, 7),
|
28 |
+
(6, 1),
|
29 |
+
(6, 9),
|
30 |
+
(8, 4),
|
31 |
+
(9, 4),
|
32 |
+
]
|
33 |
+
)
|
34 |
+
|
35 |
+
I = approx.maximum_independent_set(G)
|
36 |
+
print(f"Maximum independent set of G: {I}")
|
37 |
+
|
38 |
+
pos = nx.spring_layout(G, seed=39299899)
|
39 |
+
nx.draw(
|
40 |
+
G,
|
41 |
+
pos=pos,
|
42 |
+
with_labels=True,
|
43 |
+
node_color=["tab:red" if n in I else "tab:blue" for n in G],
|
44 |
+
)
|