How can I avoid a vertex overlapping another vertex on insert?

I have a button that adds a vertex when clicked, but I want to be able to avoid any overlap of another vertex that is already set in the graph when it is added.

I also don't want to move the other vertices from where they are on the graph when I insert the new vertex.

How can I achieve this?

asked 03 Oct '12, 13:02

mmedi005's gravatar image

mmedi005
313
accept rate: 0%

edited 03 Oct '12, 13:03


  • find a free position in the graph and insert the vertex, obviously
  • use a right mousebutton popup menu for adding a vertex and let the user put the vertex there
  • use drag/drop to let the user position a vertex, see grapheditor example
link

answered 03 Oct '12, 13:15

Lofi's gravatar image

Lofi
1.0k1221
accept rate: 37%

I want to go any of those ways, but because of how it was requested to be done, they fill out information in a small form that creates an object that represents the vertex that will be inserted.

How would you find a free position in the graph through code? Is the a set function or algorithm I need to use or make up?

(03 Oct '12, 13:20) mmedi005

Or when the user clicks finish, how can I have the new inserted vertex selected and dragging as soon as the form goes away?

(03 Oct '12, 13:23) mmedi005

You need to write your own layout algorithm. See the various examples. There's no generic example because take e. g. you have 1 single vertex in the center of the graph. Nobody can foresee where you'd want the next one (top/right/bottom/left).

(04 Oct '12, 02:02) Lofi

Thanks,

Your help definitely led me in the right direction.

(04 Oct '12, 09:38) mmedi005

any luck for achieving this ?

(05 Jan '15, 08:25) pratiktayade
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×4
×3

Asked: 03 Oct '12, 13:02

Seen: 2,694 times

Last updated: 05 Jan '15, 08:25