« first day (415 days earlier)      last day (4531 days later) » 

4:17 AM
is anybody here?
 
yup
 
I'm desperate, could somebody look at my question?
0
Q: What is wrong with my dijkstras algorithm

Stephen GranetSo I've been working on this for hours and I'm extremely frustrated. I don't understand what I'm doing wrong. I'm using Dijkstra's Algorithm to find the shortest paths between a source vertex, and 4 other vertices using an adjacency matrix. The idea behind this is that there are 5 cities and fl...

 
@StephenGranet Which is the starting vertex?
 
the startinv vertex is 2
starting
starting from, so the third one
starting from 0**
 
Can you show what your test graph looks like?
 
4:22 AM
yes, do you want the matrix or i can take a picture of the actual graph
 
If you can guarantee they match, either is fine.
 
0 110 0 0 0
110 0 245 105 230
0 245 0 115 130
0 105 115 0 95
0 230 130 95 0
0 110 0 0 0
110 0 245 105 230
0 245 0 115 130
0 105 115 0 95
0 230 130 95 0
dang, my spaces didn't work
 
You can edit posts here.
 
can you read that clearly enough?
 
Yes. Gimme a moment to draw that on paper.
 
4:24 AM
@StephenGranet I changed the tabs to spaces in your question, now I need somebody with enough juice to accept the edit, it was making my head hurt.
 
argh torrents download faster :(
 
okay, thanks :/
 
@StephenGranet It's a non-directed graph?
 
yes its not
 
What is toBeChecked?
 
4:30 AM
Can anyone familiar with Java help me with my Homework assignment? I will pay
 
Is it the colors, i.e., mark what's been visited?
 
yeah thats what it is
 
@StephenGranet wow dude, that dijkstra code you linked is U-G-L-Y
 
add me on skype, stephen
 
lol well help me make it better
 
4:31 AM
sonylords
is my username
 

Java

Dedicated to the discussion of the Java programming language a...
 
@Stephen Consider what happens on the first call to minimum.
 
@StephenGranet in c++ you can use a priority_queue to implement dijkstra pretty easily in...it may be too late for you to try now, but it's covered somewhat here: community.topcoder.com/…
 
@RMartinhoFernandes I wrote it out on paper, on the first call, it selects v as 4
 
Shouldn't it pick the one that is closest?
 
4:36 AM
@StephenGranet I agree with keith.layne - I think the data structure choice here is going to make all the difference with algorithm readability
 
yay, somebody agrees with me!
 
its not selecting the smallest distance that is adjacent to the source, is that what you're saying?
 
Right. Can you figure out why?
 
like it should check the vertices that are actually connected to the source, and then find the smallest one, not just the smallest one
yeah I can get that
and yes, im aware its not good, its my first attempt at a graph
What would be a better way to do it?
 
4:39 AM
Sorry that it's too late in the day for me to get into graph problem mode; but as far as code review goes I think you should look at at least making a simple class to represent an edge, and making a single collection of those - rather than separate currentDistance/toBeChecked/predecessor arrays
 
the graph has to have multiple levels because there are about 5 different flights between the vertices, which is why i opted for the third dimension, but if you have a suggestion,my ears are open
 
@StephenGranet Using a data structure that gives you the closest node easily. Like the aforementioned priority queue.
 
I can't, its required of the assignment that I use arrays
 
You could implement the queue yourself based on arrays, if you're familiar with heaps.
 
4:41 AM
Well, a min-heap would work nice.
(Not the most efficient, but good enough)
 
but thats a different way to go about it, one that doesn't use adjacency matrices?
I can talk to my professor tomorrow and see what he says
 
Your graph representation remains the same, it's just the structures used by the algorithm that change.
 
WTF is up with people being required to use bare arrays all the time??? I know maybe I had to do that at some point, but the STL wasn't standard then. Effing teachers these days have no excuse.
 
If you're looking around the web, node and edge are the dominant terms in graph theory.
 
@StephenGranet it's a beautiful thing to decouple the algorithm from the graph representation
 
4:43 AM
@keithlayne Were the assignment about good programming practices, it'd be half a dozen lines of Boost.Graph
 
@rvalue tell me about it, i've been googling this all day, and its hard to find examples that use arrays, and not heaps
 
@keithlayne Not very useful though. Most graph algorithms are terribly inefficient on the wrong representation.
 
@rvalue @RMartinhoFernandes curse you both!!! :P
 
Anyway, if you want to fix that one as is, I can hint you to what the bug is.
 
With all "homework" questions I remind myself that the institutions are looking to make academic researchers, not programmers.
 
4:45 AM
well, you can use an abstract singleton factory to spit out the representation :)
 
yeah, finding whats wrong is the hard part, fixing it is the easy part :)
I REALLY appreciate all the help btw
just about drop kicked my screen
 
@rvalue I would disagree from what I've seen...
 
@StephenGranet Check out the values of currentDistance on the first call of minimum.
 
@keithlayne Well, it was certainly the case at my University.
 
@rvalue yeah, my first school was much more CS theoretic, but I see a lot of VB drone factories out there now
 
4:46 AM
@RMartinhoFernandes if you want to post on the question i can give you the answer
credit for the answer
 
ah....to whore or not to whore, that is the question
2
 
@StephenGranet Let me help you get there first :)
I don't care about the points.
 
@StephenGranet most folks here would rather nudge you in the right direction than give you the answer
 
I'm fine with nudging, I wont learn anything if people just give me all the code
But I'm going to bed, im satisfied with knowing whats wrong now, I'll work on it more tomorrow
 
@StephenGranet Well, what's wrong is that currentDistance has the wrong values on the first iteration.
 
4:49 AM
and that stems from the bad minimum function
 
Not really.
 
...
I thought thats what you said
 
@StephenGranet don't take what I said the wrong way though...there are really smart folks who hang out here and are super-helpful...if you don't say "gimme teh codes" you should be okay.
 
@StephenGranet I said the values are wrong when it gets to minimum.
 
4:50 AM
In your loop, you update the distances, right?
But the first time you go look for the minimum, all the distances are still 999.
Does that make sense?
 
I thought so, the algorithm says set the distances to infinity, then set the distance of the source vertex to 0
and since none of my current paths will never be greater than 999
will eveR*
 
Sure. But what's the next step in the algorithm?
 
press the up key in the box and you can edit your posts
 
> 3. For the current node, consider all of its unvisited neighbors and calculate their tentative distances.
(from wikipedia)
 
one moment
isn't this checking if its adjacent to v?
if(adjecencyMatrix[v][i]>0)
 
4:54 AM
Sure.
 
then this checks if its been checked
if(toBeChecked[i]!=0)
 
and
if(currentDistance[i] > currentDistance[v]+adjecencyMatrix[v][i][0].ticketPrice)
oh
 
think: for the current node (at the current total distance), what would the distance be if I went to (each neighbour that isn't in the path I've taken to get to here)
 
Right, that's the "calculate their tentative distances" part.
 
4:56 AM
actually, I could be thinking A* - again too late for graphs for me; better to just listen to R. Martinh
 
shouldn't that be
this is just a stab in the dark
 
@rvalue (I've been awake for almost 24hours now, that could be a bad idea too :)
 
but currentDistance[v]?
 
no, A* is the one with heuristic prediction; ignore me entirely
 
4:58 AM
Wait, how come the first time minimum returns 4?
currentDistance[2] is set to zero.
 
because when i is 4, toBeChecked[4] is set to 1, which is true, min=999, which is equal to currentDistance[4], so it returns 4
 
But currentDistance[2] is zero. That should be the minimum.
 
yeah
idk why i thought it was 4
 
Side note: Sentinel values are bad. Sentinel values that are within the grasp of your problem space are much worse; I think you should use a much, much different value for 'infinite'
 
its late
 
5:01 AM
@RMartinhoFernandes thanks for the +2 rep. I needed that.
 
i could use the maximum possible value for an int, right
 
static const int BIG_DAMNED_NUMBER = pow(2, 30); // or INT_MAX or std::numeric_limits<int>::max()
 
Well, go to sleep then. You'll probably see things clearer tomorrow.
 
@rvalue everybody knows that infinity = 42, duh
@rvalue and I could do without you shouting obscenities in your constant names. :)
 
My last job, we used -1.0, -2.0, -3.0, ... -7.0 to represent special cases
 
5:02 AM
haha i hope so, i've been working on this bug for 4 hours
 
there was also -1e37
 
should have totally used -0.0
 
and -1e54
 
5:03 AM
Yeah, 12 year old code base converted from Delphi
 
I have to say Maybe is a pretty sweet thing
@StephenGranet good night, and good luck
 
@keithlayne And you haven't seen it rocking with monads yet!
 
Was all manner of fun when we had a new algo that'd generate values in -1 < x <= 1.0 space, let me tell you.
 
@keithlayne thanks
 
Good luck!
 
5:05 AM
@RMartinhoFernandes Maybe I have, Maybe I haven't
Just "not yet"
 
This is scary. I accidentally picked "Clojure" for the language, and this compiled: ideone.com/udA4k
 
seriously? wow.
clojure is almost appealing to me, but Java's bastard children are always almost as ugly as Java
 
@Stephen: if you're still there... you most likely got the data wrong. It works fine here: ideone.com/dPYMY (after fixing that loop to start from 0).
 
@keithlayne How do you feel about Scala?
 
huh
i just came back, i can't sleep knowing its not working
well, i pasted the matrix to you, and thats what my program output as the matrix
like i literally copied and pasted it out of my program
 
5:18 AM
@robjb I don't know so much about it, but somebody posted a long thing here about it from reddit about how it sucks enough for their company to switch back to java
 
Interesting
 
@StephenGranet What was that [0].ticketPrice thing?
(I removed it in that test code.)
 
oh
that is the flight
 
@robjb I like functional, but I have issues with Java and trying to morph goodness onto it seems almost like a lost cause
 
[0] is flight 1, [1] is flight 2
and the ticketPrice is the edge weight
 
5:19 AM
Oh. And are you sure the values you're printing are those?
 
positive
 
@keithlayne I've heard most of the common complaints on Java, but mind voicing yours? (Just curious)
 
Well, something is going wrong somewhere. The only thing wrong with the code you posted is the loop starting from 1.
 
void Graph::printMatrix()
{
cout << endl;
for(int i=0; i<MAX; i++)
{
for(int j=0;j<MAX; j++)
{
cout << adjecencyMatrix[i][j][0].ticketPrice << " ";
}
cout << endl;
}
}
this is what i used to print the matrix that i pasted to you
 
@keithlayne Part of the reason I ask is because I wonder if the things programmers take issue with are inherent to the JVM, or just Java.
 
5:22 AM
Wait!
adjecencyMatrix[v][i]>0
Ouch.
Damn you array decay to pointer.
 
what do i do
 
Shouldn't this be adjecencyMatrix[v][i][0].ticketPrice>0 as well?
 
well....it was brand new when I started programming in Java and it seemed pretty reasonable when I started (I was a student). I just grew to hate it over time, mostly because I liked C++ so much better
 
but I'm just a sheep, and the smart guys here don't like it, and I just want to be cool :P
 
5:23 AM
i love you
 
lol
 
adjecencyMatrix[v][i] is an array, and it gets converted to a pointer, and then it gets compared to 0, which will always give true. Sick.
 
rargh torrents so slow
 
I don't mind it, but I've just started using it more extensively for a larger project
And it's certainly not great
 
haha i can't believe i spent so long on something so simple
 
5:24 AM
I'd rather write C, C++, C# anyday
 
@StephenGranet Oh, everyone has one of those stories.
Now you've got yours.
 
I was initially in love with "write once, run anywhere" and became disillusioned when I learned how often that's not true
 
lmao it works!
thank you SO much!
 
it took me years to realize that I totally suck at C, and I'm okay with that
@stephen it's always that way (something silly)...I'm glad you got it figured out. Every mistake like that makes you better for next time.
 
5:26 AM
keith.layne: Well I love C#, but "write once run anywhere" isn't why
 
@keithlayne thanks, haha me too! I could have had it finished by now :(
 
yeah, I've never done C#, but I know a lot of people like it better than java
 
I prefer it to Java mainly because the language doesn't remain the same retarded shit forever.
 
^
 
@StephenGranet tell your teacher that bare arrays suck, explain how your bug was directly related to using arrays, and punch him in the face.
 
5:28 AM
I like its generics, lambda expressions, LINQ quite alot
 
he is the worst teacher, he says uhh every 3 words, and spends half the class staring at the board, confused by his own work
 
Yeah, what @keithlayne said. Minus the punching part though. That may not work in your favor.
@StephenGranet I posted an answer now, you can pick it if you want to thank me :)
 
when I saw that java had gotten generics, I thought there was hope there, then I read on how they made it work
 
0
A: What is wrong with my dijkstras algorithm

R. Martinho FernandesShouldn't this check if(adjecencyMatrix[v][i]>0) be done with adjecencyMatrix[v][i][0].ticketPrice, like the rest of the comparisons? If adjecencyMatrix[v][i] is an array, it is getting converted to a pointer, and that pointer will always compare greater than 0. Array-to-pointer decay...

 
5:29 AM
whoring won out after all...
 
@robjb Have you checked out async/await?
@keithlayne Well... I need my gold C++ badge :)
 
@RMartinhoFernandes I've read up on async / await but haven't done much with concurrency in C#, so haven't tried it first hand
Or is that coming in C# 5?
 
Yes, but there's a CTP already.
That thing looks crazy. I'm pretty sure Java won't ever have something like that.
 
I hated java io back in the day too...it was before everyone had multiple CPUs and multiple cores, but the default way to do stuff was spawning 1000000000 threads, and no async I/O
 
Yea I know
 
5:31 AM
If they fear lambdas, they won't like continuations.
 
lol
 
now that oracle has Java I don't have much hope for its future
 
@keithlayne Oh, then they added the "New I/O" API (that's the official name, in package java.nio) that has async I/O. But it sucks, so with the recent Java 7 they added the "New I/O 2" API (also the official name, in package java.nio2).
 
well, i can now sleep easy knowing that part of the program is working, take care and good night
 
Sounds almost like a joke.
@StephenGranet Good night.
 
5:33 AM
nio2? I have used nio for great good. Didn't know it was already superceded.
 
@keithlayne Agreed, and for some reason I my University is going back to Java
From teaching C# as an introductory language (as long as I've been there)
 
hmmmmmm....
 
Oh, and don't get me started on dates.
 
My instructor said there were more jobs in Java when they evaluated it.
 
First there was the horrendous Date API.
Where years start at 1900, and months start at 0. Id est, today would be new Date(111, 11, 5);
 
5:35 AM
Java was new and my teachers wanted to use it to teach OOP, which makes sense I guess to free students from constant seg faults due to pointer issues, but C++ taught right ovbiates that concern now
 
What fucking retard designed that?
 
stop talking about my mom like that
 
@RMartinhoFernandes Haha agreed.
 
Luckily, the only thing that JavaScript copied from Java was the Date API.
Oh, wait.
It's one giant pile of fail.
 
I think a lot of my issues boil down to pushing "polymorphism means inheritance" deeply into the brains of a generation of programmers
 
5:37 AM
Javascript?
 
@robjb Yes, in JavaScript, today is Date(111, 11, 5).
 
I've come to think Javascript's alright, although I didn't used to like it
Oh. That's still pretty retarded.
 
It's the only thing they copied.
 
being away from programming and coming back years later I was flabbergasted that Java and JS survived
 
That, and the name.
 
5:38 AM
Heh, never understood that tbh.
 
@robjb I have to be honest though, it frightens me as much that your school was pushing teaching C#
 
It was an introductory thing for OOP, the same reason your school taught Java when it was new.
 
I rant all the time about it, but MS really pushes their stuff on schools
 
I didn't have any C# class.
 
Maybe the same thing was happening to us? All of the computers pretty much on campus ran solaris. Maybe I blinded myself to that, it only just occured to me.
 
5:41 AM
Started with Haskell, then C, Prolog, Java, more Haskell, more C, some more Java, Prolog again, and even more Haskell.
 
but I went to a pretty good school where the teachers probably wouldn't take that kind of pressure well
 
I would have liked that curriculum
 
Haskell is pretty big on my university.
 
Not sure about the prolog
 
@robjb I ended up liking it.
 
5:42 AM
see, haskell was in its infancy then too, I wish I had learned about it
 
But only by the second round.
 
the programming language lovers were all about Scheme. I still like it probably more than the other Lisps.
 
We started C#, then they allowed a language of choice in my data structures class... then my OS class was all kernel programming in C
Then LISP and more C in my programming languages course
I've been writing Java on this project just because of a need for portability
 
C++ has come so far...I hope it makes a comeback in schools. Everything you need is built-in now, and much better practices have been established.
what type of platforms you targeting?
what is prolog? Isn't it a sort of declarative logic language or something?
 
Just Ubuntu/WindowsXP/7, but we had a lot of work to do for our time constraints
Yes, declarative logic
 
5:46 AM
you mean you needed a GUI
I never learned prolog but sometimes when I google my brain I get hits
 
Well yes.
 
Better not mention Prolog much, at least not while DeadMG can hear us.
 
I simultaneously love and hate that about java...gui stuff in the standard library
 
I wanted to do use C#, but our instructor urged against it for some reason. I wonder how GUI development is under Mono?
 
Prolog Prolog Prolog Prolog Prolog Prolog Prolog Prolog Prolog Prolog Prolog Prolog Prolog Prolog Prolog Prolog Prolog Prolog Prolog Prolog Prolog Prolog Prolog Prolog Prolog Prolog Prolog Prolog Prolog Prolog Prolog Prolog Prolog Prolog Prolog Prolog Prolog Prolog Prolog Prolog Prolog Prolog Prolog Prolog Prolog Prolog Prolog Prolog Prolog Prolog Prolog Prolog
 
5:48 AM
lol
 
he can't hear me anyway
 
@robjb There's a Windows.Forms implementation but it's not as polished as GTK#.
 
That's unfortunate
 
GTK# is portable.
 
I had hoped perhaps they would map the language API to a GTK# implementation
 
5:49 AM
poo on gui frameworks
 
We hated all the Java frameworks so much though, we went with Qt-Jambi
 
wow
 
A C++ framework wrapped for Java :p
 
if you're doing qt, just do qt then....
 
Yeaaa.
 
5:50 AM
it's probably at least as easy I would think, designer is pretty good if I remember
 
Qt Jambi uses the same designer
 
Dammit, I think I got revenge downvoted.
 
I thought Jambi died?
 
No, survives as a community effort
 
I wouldn't really call it revenge...I just don't like you :P
does it implement abstractQtGUIFactoryBeanSingleton?
 
5:52 AM
Needs more adapters.
 
hahah what?
 
just a little joke
Is swing dead, or what?
as in the java gui thing, not the music
 
It seems to be somewhat prevalent in the Java community
 
you mean swing?
 
We didn't like it, felt outdated, unproductive, and widget toolkit seemed limited
Yes
 
5:54 AM
What annoys me most about the downvote is that I carefully adjusted my rep to a multiple of five, and now this guy comes along and BAM! -2 without comment. And it isn't even prime now.
 
But these are 3 weeks experience talking, there was a lot of rapid prototyping and discarding anything that didn't work quickly
 
how does jambi do the signal/slot stuff? listener classes?
 
Large project for 2 semesters
I'm not sure, it hides the implementation nicely
 
are you good with Qt too?
 
You define a method to handle the signal, and then call
 
5:56 AM
I have lusted after it for many years, but still never done anything substantial with it
 
widgetName.signal.connect(objectWithMethodToCall, "slotMethodName");
 
Haha, objectWithMethodToCall.
:P
 
ooh, it really uses the string there?
 
:P
Yea, I thought that was awkward
Throws runtime exception if it doesn't exist
 
reflection?
 
5:57 AM
I bet you're screaming for lambdas.
 
I don't know how to scream in greek
 
Haha yea. I feel like I'm playing with C#'s retarded step-cousin
4
 
ΛΙΚΕ ΤΗΙΣ!
 
put away your character map for five seconds, will ya?
DŽ ŊŨŢŚ
 

« first day (415 days earlier)      last day (4531 days later) »