public function saveEdge($graph, $from, $to, $label = null, $document, $collection = null)
    {
        if ($graph instanceof Graph) {
            $graph = $graph->getKey();
        }

        if ($collection === null) {
            $edgeCollections      = $this->getEdgeCollections($graph);
            $edgeCollectionsCount = count($edgeCollections);
            if ($edgeCollectionsCount !== 1) {
                throw new ClientException('A collection must be provided.');
            }

            if ($edgeCollectionsCount === 1) {
                $collection = $edgeCollections[0];
            }
        }

        if (is_array($document)) {
            $_edgeClass = $this->_edgeClass;
            $document = $_edgeClass::createFromArray($document);
        }
        if (null !== $label) {
            $document->set('$label', $label);
        }
        $document->setFrom($from);
        $document->setTo($to);
        $data                 = $document->getAll();
        $data[self::KEY_FROM] = $from;
        $data[self::KEY_TO]   = $to;

        $url = UrlHelper::buildUrl(Urls::URL_GRAPH, [$graph, Urls::URLPART_EDGE, $collection]);

        $response = $this->getConnection()->post($url, $this->json_encode_wrapper($data));

        $jsonArray = $response->getJson();
        $edge      = $jsonArray['edge'];

        $document->setInternalId($edge[Edge::ENTRY_ID]);
        $document->setRevision($edge[Edge::ENTRY_REV]);

        $document->setIsNew(false);

        return $document->getInternalId();
    }