Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7824305
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T08:33:19+00:00 2026-06-02T08:33:19+00:00

I am trying to extract semantics from graphical xy plots where the points are

  • 0

I am trying to extract semantics from graphical xy plots where the points are plotted and some or all have a label. The label is plotted “near the point” so that a human can normally understand which label goes with which point. For example in this plot it is clear which label(number) belongs to which point(*) and an algorithm based on Euclidian distance would work. (The labels and points have no semantic ordering – e.g. a scatterplot)

 *1
    *2

        *3

      *4

In congested plots the authoring software/human may place the label in different directions to avoid overlap. For example in

1**2
 **4
 3

A human reader can normally work out which label is associated with which label.

One solution I’d accept would be to create a Euclidean distance matrix and shuffle the rows to get the minimum of a function (e.g. the summed squares of the distances on the diagonal or other heuristic). In the second example (with the points labelled a,b,c,d clockwise from the NW corner) we have a distance matrix (to 1 d.p.)

             a   b   c   d
 1ab2    1  1.0 2.0 2.2 1.4    
  dc4    2  2.0 1.0 1.4 2.2
  3      3  2.0 2.2 1.4 1.0
         4  2.2 1.4 1.0 2.0

and we need to label a1 b2 c4 d3. Swapping rows 3 and 4 gives the minimum sum of the diagonal. Here’s a more complex example where simply picking the nearest may fail

 *1*2*5
  **4
  3 *6

If this is solved then I shall need to go to cases where the number of labels may be smaller or larger than the number of points.

If the algorithm is standard than I would appreciate a pointer to Open Source Java (e.g. JAMA or Apache maths)

NOTE: This SO answer Associating nearby points with a path doesn’t quite work as an answer because the path through the points is given.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T08:33:21+00:00Added an answer on June 2, 2026 at 8:33 am

    You have a complete bipartite graph that one part is numbers and other one is points. Weight’s of edge in this graph is euclidean distance between numbers and points. And you’re task is finding matching with minimal weight.

    This is known problem and has a well known algorithm named as Hungarian Algorithm:

    From Wiki:

    We are given a nonnegative n×n matrix, where the element in the i-th
    row and j-th column represents the cost of assigning the j-th point to
    the i-th number. We have to find an assignment of the point to the
    numbers that has minimum cost. If the goal is to find the assignment
    that yields the maximum cost, the problem can be altered to fit the
    setting by replacing each cost with the maximum cost subtracted by the
    cost.

    The algorithm is easier to describe if we formulate the problem using
    a bipartite graph. We have a complete bipartite graph G=(S, T; E) with
    n number vertices (S) and n point vertices (T), and each edge has a
    nonnegative cost c(i,j). We want to find a perfect matching with
    minimum cost. The Hungarian method is a combinatorial optimization
    algorithm which solves the assignment problem in polynomial time and
    which anticipated later primal-dual methods. f

    For detailed algorithm and code you can take a look at topcoder article
    and this pdf maybe to use

    there is a media file to describe it.
    (This video explains why the Hungarian algorithm works)

    algorithm :
    step 1:- prepare a cost matrix.if the cost matrix is not a square
    matrix then add a dummy row(column) with zero cost element.

    step 2:- subtract the minimum element in each row from all the
    elements of the respective rows.

    step 3:- further modify the resulting matrix by subtracting the
    minimum elememnt of each column from all the elements of the
    respective columns.thus obtain the modified matrix.

    step 4:- then,draw minimum no of horizontal and vertical lines to
    cover all zeros in the resulting matrix.let the minimum no of lines be
    N.now there are 2 possible cases.

    case 1 – if N=n,where n is the order of matrix,then an optimal
    assignment can be made.so make the assignment to get the required
    solution.

    case 2 – if N less than n then proceed to step 5

    step 5: determine the smallest uncovered element in the
    matrix(element not covered by N lines).subtract this minimum element
    from all uncovered elements and add the same elements at the
    intersection of horizontal and vertical lines.thus the second modified
    matrix is obtained.

    step 6:- repeat step(3) and (4) untill we get the case (1) of step 4.

    step 7:- (to make zero assignments) examine the rows successively
    untill a row-wise exactly single zero is found.circle(o) this zero to
    make the assignment.then mark a cross(x) over all zeros if lying in
    the column of the circled zero,showing that they can’t be considered
    for future assignment.continue in this manner untill all the zeros
    have been examined. repeat the same procedure for column also.

    step 8:- repeat the step 6 succeccively until one of the following
    situation arises- (i)if no unmarked zeros is left,then the process
    ends or (ii) if there lies more than one of the unmarked zero in any
    column or row then,circle one of the unmarked zeros arbitrarily and
    mark a cross in the cell of remaining zeros in its row or
    column.repeat the process untill no unmarked zero is left in the
    matrix.

    step 9:- thus exactly one marked circled zero in each row and each
    column of the matrix is obtained. the assignment corresponding to
    these marked circle zeros will give the optimal assignment.

    For details see wiki and http://www.ams.jhu.edu/~castello/362/Handouts/hungarian.pdf

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to extract data from a data file that's tab-delimited (in some parts),
I'm trying to extract properly some cookies from a web request. Basically i have
I am trying to extract some info from a website using simple_html_dom. Currently I
I am trying extract some information from the below given string >>> st =
I'm trying to extract strings from a text that features two different types of
I am trying to extract some data from a private forum. I created a
I am trying to extract some meta data from Oracle about foreign keys. I
I'm trying to extract all matches from a EBML definition, which is something like
im trying to extract some files from a jar-file downloaded using java-webstart. below code
I'm trying to extract all of the links to image files from a text

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.