Results 1 to 8 of 8
  1. #1
    MattTuck is offline Member
    Join Date
    Mar 2015
    Location
    A Place With Windows
    Posts
    71
    Rep Power
    0

    Default How to build a Graph based off of data in a .txt File?

    Hey guys, I'm trying to build an app that will build a graph from user inputs stored in a .txt file. Advice? Experience?

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    14,423
    Blog Entries
    7
    Rep Power
    27

    Default Re: How to build a Graph based off of data in a .txt File?

    It all depends how you've modeled your graph in text form; adjacency matrix/list? edge/vertices list?

    kind regards,

    Jos
    Build a wall around Donald Trump; I'll pay for it.

  3. #3
    MattTuck is offline Member
    Join Date
    Mar 2015
    Location
    A Place With Windows
    Posts
    71
    Rep Power
    0

    Default Re: How to build a Graph based off of data in a .txt File?

    Matrix/List Format.... It's a list of grades for multiple students... I want to graph one student's grade against the average, with connecting vertices between points. And to scale it so that the grades begin at (1,y) as opposed to (0,y)...

  4. #4
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    14,423
    Blog Entries
    7
    Rep Power
    27

    Default Re: How to build a Graph based off of data in a .txt File?

    Quote Originally Posted by MattTuck View Post
    Matrix/List Format.... It's a list of grades for multiple students... I want to graph one student's grade against the average, with connecting vertices between points. And to scale it so that the grades begin at (1,y) as opposed to (0,y)...
    Can you show us a (small) example? Are students the vertices of the graph? What are the edges of the graph? Or do you want to graph (render/draw) the results of it all?

    kind regards,

    Jos
    Build a wall around Donald Trump; I'll pay for it.

  5. #5
    MattTuck is offline Member
    Join Date
    Mar 2015
    Location
    A Place With Windows
    Posts
    71
    Rep Power
    0

    Default Re: How to build a Graph based off of data in a .txt File?

    Sure, the .txt file would read something like this

    Tom Mac /t 96.5 /t 65.3 /t 73.8.....
    Beth Stibs /t 45.3 /t 99.1 /t 100....
    .
    .
    .

  6. #6
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    14,423
    Blog Entries
    7
    Rep Power
    27

    Default Re: How to build a Graph based off of data in a .txt File?

    Quote Originally Posted by MattTuck View Post
    Sure, the .txt file would read something like this

    Tom Mac /t 96.5 /t 65.3 /t 73.8.....
    Beth Stibs /t 45.3 /t 99.1 /t 100....
    .
    .
    .
    So there's one student per line and the fields in each line are separated by a tab (assuming /t represents a tab character (\t)); have you tried to split those fields and convert them to double numbers (except for the first field because that's a name).
    Hint: look at the String.split( ... ) method and the Double.parseDouble( ... ) method.

    kind regards,

    Jos
    Build a wall around Donald Trump; I'll pay for it.

  7. #7
    MattTuck is offline Member
    Join Date
    Mar 2015
    Location
    A Place With Windows
    Posts
    71
    Rep Power
    0

    Default Re: How to build a Graph based off of data in a .txt File?

    Yea, the idea was to pull and store that data in an object, and use that object to build the graph.... something like
    Student("first name", "last name", int grade1, int grade2, ...ect)

  8. #8
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    14,423
    Blog Entries
    7
    Rep Power
    27

    Default Re: How to build a Graph based off of data in a .txt File?

    Quote Originally Posted by MattTuck View Post
    Yea, the idea was to pull and store that data in an object, and use that object to build the graph.... something like
    Student("first name", "last name", int grade1, int grade2, ...ect)
    First model that class: a Student has a first name and a last name and a list (or array) of grades. Can those grades be ints? Given the input, my guess would be that they have to be floats or doubles. Design a constructor (or more!) for a Student and methods that'd come in handy ...

    kind regards,

    Jos
    Build a wall around Donald Trump; I'll pay for it.

Similar Threads

  1. how to build web based image editor ?
    By Tlipre in forum JavaServer Pages (JSP) and JSTL
    Replies: 1
    Last Post: 02-21-2014, 09:05 PM
  2. How to plot the graph,where the data from text file?
    By Haryanti in forum New To Java
    Replies: 2
    Last Post: 12-01-2011, 06:11 PM
  3. java graph plot taking file data
    By niloR19 in forum AWT / Swing
    Replies: 3
    Last Post: 11-28-2011, 06:56 PM
  4. Reading data from csv file based on specific input
    By jaiminparikh in forum Advanced Java
    Replies: 14
    Last Post: 02-13-2009, 09:07 PM
  5. Replies: 0
    Last Post: 04-04-2008, 09:36 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •