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


Python networkx.write_pajek方法代码示例

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


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

示例1: write_graph

# 需要导入模块: import networkx [as 别名]
# 或者: from networkx import write_pajek [as 别名]
def write_graph(self, G=None, subgraph_file=None):
        if G is None:
            G = self.context_graph
        if subgraph_file is None:
            subgraph_file = self.context_graph_file
        logging.info("Writing graph.")
        # write the graph out
        file_format = subgraph_file.split(".")[-1]
        if file_format == "graphml":
            nx.write_graphml(G, subgraph_file)
        elif file_format == "gml":
            nx.write_gml(G, subgraph_file)
        elif file_format == "gexf":
            nx.write_gexf(G, subgraph_file)
        elif file_format == "net":
            nx.write_pajek(G, subgraph_file)
        elif file_format == "yaml":
            nx.write_yaml(G, subgraph_file)
        elif file_format == "gpickle":
            nx.write_gpickle(G, subgraph_file)
        else:
            print "File format not found, writing graphml."
            nx.write_graphml(G, subgraph_file) 
开发者ID:vz-risk,项目名称:Verum,代码行数:25,代码来源:networkx.py

示例2: save_net_nx_graph

# 需要导入模块: import networkx [as 别名]
# 或者: from networkx import write_pajek [as 别名]
def save_net_nx_graph(nx_graph, output_directory, output_file_name):
    """ 
        Saves the input graph in pajek (.net) format

    Args:
        nx_graph(str): networkx graph object to be saved
        output_drectory(str): location to save graph
        output_file_name(str): name of the image file to be saved

    Returns:
       null

    """
    if config.DEBUGGER:
        print "Generating", (output_file_name + ".net")
    check_if_dir_exists(output_directory) #create output directory if doesn't exist
    nx.write_pajek(nx_graph, output_directory + "/" + output_file_name +".net") 
开发者ID:prasadtalasila,项目名称:IRCLogParser,代码行数:19,代码来源:saver.py

示例3: write_pajek

# 需要导入模块: import networkx [as 别名]
# 或者: from networkx import write_pajek [as 别名]
def write_pajek(G, path, encoding='UTF-8'):
    """Write graph in Pajek format to path.

    Parameters
    ----------
    G : graph
       A Networkx graph
    path : file or string
       File or filename to write.
       Filenames ending in .gz or .bz2 will be compressed.

    Examples
    --------
    >>> G=nx.path_graph(4)
    >>> nx.write_pajek(G, "test.net")

    References
    ----------
    See http://vlado.fmf.uni-lj.si/pub/networks/pajek/doc/draweps.htm
    for format information.
    """
    for line in generate_pajek(G):
        line+='\n'
        path.write(line.encode(encoding)) 
开发者ID:SpaceGroupUCL,项目名称:qgisSpaceSyntaxToolkit,代码行数:26,代码来源:pajek.py

示例4: write_pajek

# 需要导入模块: import networkx [as 别名]
# 或者: from networkx import write_pajek [as 别名]
def write_pajek(G, path, encoding='UTF-8'):
    """Write graph in Pajek format to path.

    Parameters
    ----------
    G : graph
       A Networkx graph
    path : file or string
       File or filename to write.
       Filenames ending in .gz or .bz2 will be compressed.

    Examples
    --------
    >>> G=nx.path_graph(4)
    >>> nx.write_pajek(G, "test.net")

    References
    ----------
    See http://vlado.fmf.uni-lj.si/pub/networks/pajek/doc/draweps.htm
    for format information.
    """
    for line in generate_pajek(G):
        line += '\n'
        path.write(line.encode(encoding)) 
开发者ID:aws-samples,项目名称:aws-kube-codesuite,代码行数:26,代码来源:pajek.py

示例5: HACK_convert_nx_igraph

# 需要导入模块: import networkx [as 别名]
# 或者: from networkx import write_pajek [as 别名]
def HACK_convert_nx_igraph(nx_graph):
    """ 
        There exist no current method to convert a nx graph to an igraph.
        So this is a hack which does sp.
        Args:
            nx_graph: input nx_graph to be converted to igraph
        Returns:
            ig_graph: converted igraph
    """
    nx.write_pajek(nx_graph, "/tmp/rohan.net")
    ig_graph = igraph.Graph()
    ig_graph = igraph.read("/tmp/rohan.net", format="pajek")
    return ig_graph 
开发者ID:prasadtalasila,项目名称:IRCLogParser,代码行数:15,代码来源:util.py

示例6: read_pajek

# 需要导入模块: import networkx [as 别名]
# 或者: from networkx import write_pajek [as 别名]
def read_pajek(path, encoding='UTF-8'):
    """Read graph in Pajek format from path.

    Parameters
    ----------
    path : file or string
       File or filename to write.
       Filenames ending in .gz or .bz2 will be uncompressed.

    Returns
    -------
    G : NetworkX MultiGraph or MultiDiGraph.

    Examples
    --------
    >>> G=nx.path_graph(4)
    >>> nx.write_pajek(G, "test.net")
    >>> G=nx.read_pajek("test.net")

    To create a Graph instead of a MultiGraph use

    >>> G1=nx.Graph(G)

    References
    ----------
    See http://vlado.fmf.uni-lj.si/pub/networks/pajek/doc/draweps.htm
    for format information.
    """
    lines = (line.decode(encoding) for line in path)
    return parse_pajek(lines) 
开发者ID:SpaceGroupUCL,项目名称:qgisSpaceSyntaxToolkit,代码行数:32,代码来源:pajek.py

示例7: write_pajek

# 需要导入模块: import networkx [as 别名]
# 或者: from networkx import write_pajek [as 别名]
def write_pajek(G, path, encoding='UTF-8'):
    """Write graph in Pajek format to path.

    Parameters
    ----------
    G : graph
       A Networkx graph
    path : file or string
       File or filename to write.
       Filenames ending in .gz or .bz2 will be compressed.

    Examples
    --------
    >>> G=nx.path_graph(4)
    >>> nx.write_pajek(G, "test.net")

    Warnings
    --------
    Optional node attributes and edge attributes must be non-empty strings.
    Otherwise it will not be written into the file. You will need to
    convert those attributes to strings if you want to keep them.

    References
    ----------
    See http://vlado.fmf.uni-lj.si/pub/networks/pajek/doc/draweps.htm
    for format information.
    """
    for line in generate_pajek(G):
        line += '\n'
        path.write(line.encode(encoding)) 
开发者ID:holzschu,项目名称:Carnets,代码行数:32,代码来源:pajek.py

示例8: androcg_main

# 需要导入模块: import networkx [as 别名]
# 或者: from networkx import write_pajek [as 别名]
def androcg_main(verbose,
                 APK,
                 classname,
                 methodname,
                 descriptor,
                 accessflag,
                 no_isolated,
                 show,
                 output):
    from androguard.core.androconf import show_logging
    from androguard.core.bytecode import FormatClassToJava
    from androguard.misc import AnalyzeAPK
    import networkx as nx
    import logging
    log = logging.getLogger("androcfg")
    if verbose:
        show_logging(logging.INFO)

    a, d, dx = AnalyzeAPK(APK)

    entry_points = map(FormatClassToJava,
                       a.get_activities() + a.get_providers() +
                       a.get_services() + a.get_receivers())
    entry_points = list(entry_points)

    log.info("Found The following entry points by search AndroidManifest.xml: "
             "{}".format(entry_points))

    CG = dx.get_call_graph(classname,
                           methodname,
                           descriptor,
                           accessflag,
                           no_isolated,
                           entry_points,
                           )

    write_methods = dict(gml=_write_gml,
                         gexf=nx.write_gexf,
                         gpickle=nx.write_gpickle,
                         graphml=nx.write_graphml,
                         yaml=nx.write_yaml,
                         net=nx.write_pajek,
                         )

    if show:
        plot(CG)
    else:
        writer = output.rsplit(".", 1)[1]
        if writer in ["bz2", "gz"]:
            writer = output.rsplit(".", 2)[1]
        if writer not in write_methods:
            print("Could not find a method to export files to {}!"
                  .format(writer))
            sys.exit(1)

        write_methods[writer](CG, output) 
开发者ID:amimo,项目名称:dcc,代码行数:58,代码来源:main.py


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