Как изменить края & # 39; вес по обозначенному правилу?

Используйте опцию -print-file-name gcc:

$ gcc -print-file-name=libc.so
/usr/lib/gcc/x86_64-redhat-linux/4.5.1/../../../../lib64/libc.so

Это дает путь. Теперь:

$ file /usr/lib/gcc/x86_64-redhat-linux/4.5.1/../../../../lib64/libc.so
/usr/lib/gcc/x86_64-redhat-linux/4.5.1/../../../../lib64/libc.so: ASCII C program text

$ cat /usr/lib/gcc/x86_64-redhat-linux/4.5.1/../../../../lib64/libc.so
/* GNU ld script
   Use the shared library, but some functions are only in
   the static library, so try that secondarily.  */
OUTPUT_FORMAT(elf64-x86-64)
GROUP ( /lib64/libc.so.6 /usr/lib64/libc_nonshared.a  AS_NEEDED ( /lib64/ld-linux-x86-64.so.2 ) )

Выглядит как скрипт компоновщика. libc является особенным в Linux, поскольку он может быть выполнен:

$ /lib64/libc.so.6
GNU C Library stable release version 2.13, by Roland McGrath et al.
Copyright (C) 2011 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.
Compiled by GNU CC version 4.5.1 20100924 (Red Hat 4.5.1-4).
Compiled on a Linux 2.6.35 system on 2011-08-05.
Available extensions:
    Support for some architectures added on, not maintained in glibc core.
    The C stubs add-on version 2.1.2.
    crypt add-on version 2.1 by Michael Glad and others
    GNU Libidn by Simon Josefsson
    Native POSIX Threads Library by Ulrich Drepper et al
    BIND-8.2.3-T5B
    RT using linux kernel aio
libc ABIs: UNIQUE IFUNC
For bug reporting instructions, please see:
<http://www.gnu.org/software/libc/bugs.html>.
16
задан double-beep 20 May 2019 в 15:55
поделиться

1 ответ

Вы можете получить доступ к весу ребра как G [u] [v] ['weight'] или перебирая данные ребра. Таким образом, вы можете, например,

In [1]: import networkx as nx

In [2]: G=nx.DiGraph()

In [3]: G.add_edge(1,2,weight=10)

In [4]: G.add_edge(2,3,weight=20)

In [5]: G[2][3]['weight']
Out[5]: 20

In [6]: G[2][3]['weight']=200

In [7]: G[2][3]['weight']
Out[7]: 200

In [8]: G.edges(data=True)
Out[8]: [(1, 2, {'weight': 10}), (2, 3, {'weight': 200})]

In [9]: for u,v,d in G.edges(data=True):
   ...:     d['weight']+=7
   ...:     
   ...:     

In [10]: G.edges(data=True)
Out[10]: [(1, 2, {'weight': 17}), (2, 3, {'weight': 207})]
29
ответ дан Aric 20 May 2019 в 15:55
поделиться
Другие вопросы по тегам:

Похожие вопросы: