定制 graphp/graphml 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

graphp/graphml

最新稳定版本:v0.1.0

Composer 安装命令:

composer require graphp/graphml

包简介

GraphML is an XML-based file format for graphs

README 文档

README

CI status

GraphML is an XML-based file format for graphs

Note: This project is in early beta stage! Feel free to report any issues you encounter.

Table of contents

Usage

Exporter

getOutput()

The getOutput(Graph $graph): string method can be used to export the given graph instance.

$graph = new Fhaculty\Graph\Graph();

$a = $graph->createVertex('a');
$b = $graph->createVertex('b');
$a->createEdgeTo($b);

$exporter = new Graphp\GraphML\Exporter();
$data = $exporter->getOutput($graph);

file_put_contents('example.graphml', $data);

This method only supports exporting the basic graph structure, with all vertices and directed and undirected edges.

Note that none of the attributes attached to any objects nor any of the "advanced concepts" of GraphML (Nested Graphs, Hyperedges and Ports) are currently implemented. We welcome PRs!

Loader

loadContents()

The loadContents(string $contents): Graph method can be used to load a graph instance from the given GraphML contents.

$data = file_get_contents('example.graphml');

$loader = new Graphp\GraphML\Loader();
$graph = $loader->loadContents($data);

foreach ($graph->getVertices() as $vertex) {
    foreach ($vertex->getVerticesEdgeTo() as other) {
        echo $vertex->getId() . ' connected with ' . $other->getId() . PHP_EOL;
    }
}

This method supports loading the graph, all vertices and directed and undirected edges among with any attributes attached from the GraphML source.

Note that neither of the "advanced concepts" of GraphML (Nested Graphs, Hyperedges and Ports) are currently implemented. We welcome PRs!

Install

The recommended way to install this library is through composer. New to composer?

{
    "require": {
        "graphp/graphml": "~0.1.0"
    }
}

This project aims to run on any platform and thus does not require any PHP extensions and supports running on legacy PHP 5.3 through current PHP 7+ and HHVM. It's highly recommended to use PHP 7+ for this project.

Tests

To run the test suite, you first need to clone this repo and then install all dependencies through Composer:

$ composer install

To run the test suite, go to the project root and run:

$ php vendor/bin/phpunit

License

Released under the terms of the permissive MIT license.

统计信息

  • 总下载量: 6.71k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 28
  • 点击次数: 1
  • 依赖项目数: 2
  • 推荐数: 0

GitHub 信息

  • Stars: 28
  • Watchers: 2
  • Forks: 9
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-01-18

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固