diff --git a/CHANGELOG.md b/CHANGELOG.md index 83a08f9..53d4999 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Fixed + * Drawing an edge always inserts a directed edge even if the graph is not a directed graph, which results in "syntax error" #237 + ## [1.1.0] - 2024-02-11 ### Changed diff --git a/src/Graph.js b/src/Graph.js index 399a54b..616e00e 100644 --- a/src/Graph.js +++ b/src/Graph.js @@ -423,10 +423,11 @@ class Graph extends React.Component { var endNode = d3_select(event.currentTarget); var startNodeName = this.startNode.selectWithoutDataPropagation("title").text(); var endNodeName = endNode.selectWithoutDataPropagation("title").text(); + const edgeop = this.dotGraph.edgeop; this.graphviz .insertDrawnEdge(startNodeName + '->' + endNodeName); this.latestEdgeAttributes = Object.assign({}, this.props.defaultEdgeAttributes); - this.dotGraph.insertEdge(startNodeName, endNodeName, this.latestEdgeAttributes); + this.dotGraph.insertEdge(startNodeName, endNodeName, edgeop, this.latestEdgeAttributes); this.props.onTextChange(this.dotGraph.dotSrc); } this.isDrawingEdge = false; diff --git a/src/dot.js b/src/dot.js index 39d09f0..a66ebba 100644 --- a/src/dot.js +++ b/src/dot.js @@ -21,9 +21,9 @@ export default class DotGraph { this.insertAtEndOfGraph(newNodeString + '\n'); } - insertEdge(startNodeName, endNodeName, attributes) { + insertEdge(startNodeName, endNodeName, edgeop, attributes) { var attributesString = toAttributesString(attributes); - var newEdgeString = ' ' + quoteIdIfNecessary(startNodeName) + ' -> ' + quoteIdIfNecessary(endNodeName) + attributesString; + var newEdgeString = ' ' + quoteIdIfNecessary(startNodeName) + ' ' + edgeop + ' ' + quoteIdIfNecessary(endNodeName) + attributesString; this.insertAtEndOfGraph(newEdgeString + '\n'); }