当前位置: 首页>>代码示例>>Python>>正文


Python networkx.__version__方法代码示例

本文整理汇总了Python中networkx.__version__方法的典型用法代码示例。如果您正苦于以下问题:Python networkx.__version__方法的具体用法?Python networkx.__version__怎么用?Python networkx.__version__使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在networkx的用法示例。


在下文中一共展示了networkx.__version__方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: check6_bsddb3

# 需要导入模块: import networkx [as 别名]
# 或者: from networkx import __version__ [as 别名]
def check6_bsddb3(self):
        '''bsddb3 - Python Bindings for Oracle Berkeley DB

        requires Berkeley DB

        PY_BSDDB3_VER_MIN = (6, 0, 1) # 6.x series at least
        '''
        self.append_text("\n")
        # Start check

        try:
            import bsddb3 as bsddb
            bsddb_str = bsddb.__version__  # Python adaptation layer
            # Underlying DB library
            bsddb_db_str = str(bsddb.db.version()).replace(', ', '.')\
                .replace('(', '').replace(')', '')
        except ImportError:
            bsddb_str = 'not found'
            bsddb_db_str = 'not found'

        result = ("* Berkeley Database library (bsddb3: " + bsddb_db_str +
                  ") (Python-bsddb3 : " + bsddb_str + ")")
        # End check
        self.append_text(result) 
开发者ID:gramps-project,项目名称:addons-source,代码行数:26,代码来源:PrerequisitesCheckerGramplet.py

示例2: check_fontconfig

# 需要导入模块: import networkx [as 别名]
# 或者: from networkx import __version__ [as 别名]
def check_fontconfig(self):
        ''' The python-fontconfig library is used to support the Genealogical
        Symbols tab of the Preferences.  Without it Genealogical Symbols don't
        work '''
        try:
            import fontconfig
            vers = fontconfig.__version__
            if vers.startswith("0.5."):
                result = ("* python-fontconfig " + vers +
                          " (Success version 0.5.x is installed.)")
            else:
                result = ("* python-fontconfig " + vers +
                          " (Requires version 0.5.x)")
        except ImportError:
            result = "* python-fontconfig Not found, (Requires version 0.5.x)"
        # End check
        self.append_text(result)

    #Optional 
开发者ID:gramps-project,项目名称:addons-source,代码行数:21,代码来源:PrerequisitesCheckerGramplet.py

示例3: check23_pedigreechart

# 需要导入模块: import networkx [as 别名]
# 或者: from networkx import __version__ [as 别名]
def check23_pedigreechart(self):
        '''PedigreeChart - Can optionally use - NumPy if installed

        https://github.com/gramps-project/addons-source/blob/master/PedigreeChart/PedigreeChart.py
        '''
        self.append_text("\n")
        self.render_text("""<b>03. <a href="https://gramps-project.org/wiki"""
                         """/index.php?title=PedigreeChart">"""
                         """Addon:PedigreeChart</a> :</b> """)
        # Start check

        try:
            import numpy
            numpy_ver = str(numpy.__version__)
            #print("numpy.__version__ :" + numpy_ver )
            # NUMPY_check = True
        except ImportError:
            numpy_ver = "Not found"
            # NUMPY_check = False

        result = "(NumPy : " + numpy_ver + " )"
        # End check
        self.append_text(result)
        #self.append_text("\n") 
开发者ID:gramps-project,项目名称:addons-source,代码行数:26,代码来源:PrerequisitesCheckerGramplet.py

示例4: print_versions

# 需要导入模块: import networkx [as 别名]
# 或者: from networkx import __version__ [as 别名]
def print_versions(file: typing.TextIO = None) -> None:
    """
    Print version strings of currently installed dependencies

     ``> python -m quantumflow.meta``


    Args:
        file: Output stream. Defaults to stdout.
    """

    print('** QuantumFlow dependencies (> python -m quantumflow.meta) **')
    print('quantumflow \t', qf.__version__, file=file)
    print('python      \t', sys.version[0:5], file=file)
    print('numpy       \t', np.__version__, file=file)
    print('networkx    \t', nx.__version__, file=file)
    print('cvxpy      \t', cvx.__version__, file=file)
    print('pyquil      \t', pyquil.__version__, file=file)

    print(bk.name, '   \t', bk.version, '(BACKEND)', file=file) 
开发者ID:rigetti,项目名称:quantumflow,代码行数:22,代码来源:meta.py

示例5: as_tree

# 需要导入模块: import networkx [as 别名]
# 或者: from networkx import __version__ [as 别名]
def as_tree(graph, root=OPENSTACK_CLUSTER, reverse=False):
        if nx.__version__ >= '2.0':
            linked_graph = json_graph.node_link_graph(
                graph, attrs={'name': 'graph_index'})
        else:
            linked_graph = json_graph.node_link_graph(graph)
        if 0 == nx.number_of_nodes(linked_graph):
            return {}
        if reverse:
            linked_graph = linked_graph.reverse()
        if nx.__version__ >= '2.0':
            return json_graph.tree_data(
                linked_graph,
                root=root,
                attrs={'id': 'graph_index', 'children': 'children'})
        else:
            return json_graph.tree_data(linked_graph, root=root) 
开发者ID:openstack,项目名称:vitrage,代码行数:19,代码来源:topology.py

示例6: trim

# 需要导入模块: import networkx [as 别名]
# 或者: from networkx import __version__ [as 别名]
def trim(g, max_parents=False, max_children=False):
    if float(nx.__version__) < 2:
        edgedict = g.edge
    else:
        edgedict = g.adj
    for node in g:
        if max_parents:
            parents = list(g.successors(node))
            weights = [edgedict[node][parent]['weight'] for parent in parents]
            for weak_parent in np.argsort(weights)[:-max_parents]:
                g.remove_edge(node, parents[weak_parent])
        if max_children:
            children = g.predecessors(node)
            weights = [edgedict[child][node]['weight'] for child in children]
            for weak_child in np.argsort(weights)[:-max_children]:
                g.remove_edge(children[weak_child], node)
    return g 
开发者ID:gregversteeg,项目名称:bio_corex,代码行数:19,代码来源:vis_corex.py

示例7: test_edge_id_construct

# 需要导入模块: import networkx [as 别名]
# 或者: from networkx import __version__ [as 别名]
def test_edge_id_construct(self):
        G = nx.Graph()
        G.add_edges_from([(0, 1, {'id': 0}), (1, 2, {'id': 2}), (2, 3)])
        expected = """<gexf version="1.2" xmlns="http://www.gexf.net/1.2draft" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.w3.org/2001/XMLSchema-instance">
  <graph defaultedgetype="undirected" mode="static" name="">
    <meta>
      <creator>NetworkX {}</creator>
      <lastmodified>{}</lastmodified>
    </meta>
    <nodes>
      <node id="0" label="0" />
      <node id="1" label="1" />
      <node id="2" label="2" />
      <node id="3" label="3" />
    </nodes>
    <edges>
      <edge id="0" source="0" target="1" />
      <edge id="2" source="1" target="2" />
      <edge id="1" source="2" target="3" />
    </edges>
  </graph>
</gexf>""".format(nx.__version__, time.strftime('%d/%m/%Y'))
        obtained = '\n'.join(nx.generate_gexf(G))
        assert_equal(expected, obtained) 
开发者ID:holzschu,项目名称:Carnets,代码行数:26,代码来源:test_gexf.py

示例8: check17_pillow

# 需要导入模块: import networkx [as 别名]
# 或者: from networkx import __version__ [as 别名]
def check17_pillow(self):
        '''PILLOW
        Allows Production of jpg images from non-jpg images in LaTeX documents

        #TODO prculley mentions that : And PIL (Pillow) is also used by the
        main Gramps ([]narrativeweb and []other reports for image cropping)
        as well as [x]editexifmetadata and the
        new [x]latexdoc type addons (genealogytree).

        #TODO add check for PILLOW to "gramps -v"  section

        https://github.com/gramps-project/gramps/blob/maintenance/gramps50/gramps/plugins/docgen/latexdoc.py
        '''
        #self.append_text("\n")
        # Start check

        try:
            import PIL
            # from PIL import Image
            try:
                pil_ver = PIL.__version__
            except Exception:
                try:
                    pil_ver = str(PIL.PILLOW_VERSION)
                except Exception:
                    try:
                        #print(dir(PIL))
                        pil_ver = str(PIL.VERSION)
                    except Exception:
                        pil_ver = "Installed but does not supply version"
        except ImportError:
            pil_ver = "Not found"

        result = "(PILLOW " + pil_ver + ")"
        # End check
        self.append_text(result) 
开发者ID:gramps-project,项目名称:addons-source,代码行数:38,代码来源:PrerequisitesCheckerGramplet.py

示例9: check_dependencies

# 需要导入模块: import networkx [as 别名]
# 或者: from networkx import __version__ [as 别名]
def check_dependencies(self):
        try:
            import nose
            self.logger.debug("\tNose: %s\n" % str(nose.__version__))
        except ImportError:
            raise ImportError("Nose cannot be imported. Are you sure it's "
                              "installed?")
        try:
            import networkx
            self.logger.debug("\tnetworkx: %s\n" % str(networkx.__version__))
        except ImportError:
            raise ImportError("Networkx cannot be imported. Are you sure it's "
                              "installed?")
        try:
            import pymongo
            self.logger.debug("\tpymongo: %s\n" % str(pymongo.version))
            from bson.objectid import ObjectId
        except ImportError:
            raise ImportError("Pymongo cannot be imported. Are you sure it's"
                              " installed?")
        try:
            import numpy
            self.logger.debug("\tnumpy: %s" % str(numpy.__version__))
        except ImportError:
            raise ImportError("Numpy cannot be imported. Are you sure that it's"
                              " installed?")
        try:
            import scipy
            self.logger.debug("\tscipy: %s" % str(scipy.__version__))
        except ImportError:
            raise ImportError("Scipy cannot be imported. Are you sure that it's"
                              " installed?") 
开发者ID:automl,项目名称:HPOlib,代码行数:34,代码来源:random_hyperopt_august2013_mod.py

示例10: node_iter

# 需要导入模块: import networkx [as 别名]
# 或者: from networkx import __version__ [as 别名]
def node_iter(G):
    if float(nx.__version__)<2.0:
        return G.nodes()
    else:
        return G.nodes 
开发者ID:RexYing,项目名称:diffpool,代码行数:7,代码来源:util.py

示例11: node_dict

# 需要导入模块: import networkx [as 别名]
# 或者: from networkx import __version__ [as 别名]
def node_dict(G):
    if float(nx.__version__)>2.1:
        node_dict = G.nodes
    else:
        node_dict = G.node
    return node_dict
# --------------------------- 
开发者ID:RexYing,项目名称:diffpool,代码行数:9,代码来源:util.py

示例12: get_graph

# 需要导入模块: import networkx [as 别名]
# 或者: from networkx import __version__ [as 别名]
def get_graph(graph_type, depth, query, root, all_tenants):
        TopologyController._check_input_para(graph_type,
                                             depth,
                                             query,
                                             root,
                                             all_tenants)

        try:
            graph_data = pecan.request.client.call(pecan.request.context,
                                                   'get_topology',
                                                   graph_type=graph_type,
                                                   depth=depth,
                                                   query=query,
                                                   root=root,
                                                   all_tenants=all_tenants)
            graph = decompress_obj(graph_data)
            if graph_type == 'graph':
                return graph
            if graph_type == 'tree':
                if nx.__version__ >= '2.0':
                    node_id = ''
                    for node in graph['nodes']:
                        if (root and node[VProps.VITRAGE_ID] == root) or \
                                (not root and node[VProps.ID] == CLUSTER_ID):
                            node_id = node[VProps.GRAPH_INDEX]
                            break
                else:
                    node_id = CLUSTER_ID
                    if root:
                        for node in graph['nodes']:
                            if node[VProps.VITRAGE_ID] == root:
                                node_id = node[VProps.ID]
                                break
                return TopologyController.as_tree(graph, node_id)

        except Exception:
            LOG.exception('failed to get topology.')
            abort(404, 'Failed to get topology.') 
开发者ID:openstack,项目名称:vitrage,代码行数:40,代码来源:topology.py

示例13: json_output_graph

# 需要导入模块: import networkx [as 别名]
# 或者: from networkx import __version__ [as 别名]
def json_output_graph(self, **kwargs):
        """supports both 1.10<=networkx<2.0 and networx>=2.0 by returning the

        same json output regardless networx version

        :return: graph in json format
        """

        # TODO(annarez): when we decide to support networkx 2.0 with
        # versioning of Vitrage, we can move part of the logic to vitrageclient
        node_link_data = json_graph.node_link_data(self._g)
        node_link_data.update(kwargs)

        vitrage_id_to_index = dict()

        for index, node in enumerate(node_link_data['nodes']):
            vitrage_id_to_index[node[VProps.VITRAGE_ID]] = index
            if VProps.ID in self._g.nodes[node[VProps.ID]]:
                node[VProps.ID] = self._g.nodes[node[VProps.ID]][VProps.ID]
                node[VProps.GRAPH_INDEX] = index

        vers = nx.__version__
        if vers >= '2.0':
            for i in range(len(node_link_data['links'])):
                node_link_data['links'][i]['source'] = vitrage_id_to_index[
                    node_link_data['links'][i]['source']]
                node_link_data['links'][i]['target'] = vitrage_id_to_index[
                    node_link_data['links'][i]['target']]

        if kwargs.get('raw', False):
            return node_link_data
        else:
            return json.dumps(node_link_data) 
开发者ID:openstack,项目名称:vitrage,代码行数:35,代码来源:networkx_graph.py

示例14: test_write_with_node_attributes

# 需要导入模块: import networkx [as 别名]
# 或者: from networkx import __version__ [as 别名]
def test_write_with_node_attributes(self):
        # Addresses #673.
        G = nx.OrderedGraph()
        G.add_edges_from([(0, 1), (1, 2), (2, 3)])
        for i in range(4):
            G.nodes[i]['id'] = i
            G.nodes[i]['label'] = i
            G.nodes[i]['pid'] = i
            G.nodes[i]['start'] = i
            G.nodes[i]['end'] = i + 1

        expected = """<gexf version="1.2" xmlns="http://www.gexf.net/1.2draft" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.w3.org/2001/XMLSchema-instance">
  <graph defaultedgetype="undirected" mode="dynamic" name="" timeformat="long">
    <meta>
      <creator>NetworkX {}</creator>
      <lastmodified>{}</lastmodified>
    </meta>
    <nodes>
      <node end="1" id="0" label="0" pid="0" start="0" />
      <node end="2" id="1" label="1" pid="1" start="1" />
      <node end="3" id="2" label="2" pid="2" start="2" />
      <node end="4" id="3" label="3" pid="3" start="3" />
    </nodes>
    <edges>
      <edge id="0" source="0" target="1" />
      <edge id="1" source="1" target="2" />
      <edge id="2" source="2" target="3" />
    </edges>
  </graph>
</gexf>""".format(nx.__version__, time.strftime('%d/%m/%Y'))
        obtained = '\n'.join(nx.generate_gexf(G))
        assert_equal(expected, obtained) 
开发者ID:holzschu,项目名称:Carnets,代码行数:34,代码来源:test_gexf.py

示例15: add_meta

# 需要导入模块: import networkx [as 别名]
# 或者: from networkx import __version__ [as 别名]
def add_meta(self, G, graph_element):
        # add meta element with creator and date
        meta_element = Element('meta')
        SubElement(meta_element, 'creator').text = 'NetworkX {}'.format(nx.__version__)
        SubElement(meta_element, 'lastmodified').text = time.strftime('%d/%m/%Y')
        graph_element.append(meta_element) 
开发者ID:holzschu,项目名称:Carnets,代码行数:8,代码来源:gexf.py


注:本文中的networkx.__version__方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。