I've written code in Java using the Osmosis framework and specifically OsmosisReader for Java, for OSM processing.
To do so I need to convert OSM's ways to edges between the way's source and destination.
for example, take this way:
<way id='155117788' timestamp='2021-11-04T10:33:53Z' uid='1935374' user='alxm' visible='true' version='16' changeset='113364120'>
<nd ref='985633394' />
<nd ref='5329510726' />
<nd ref='7203635659' />
<nd ref='5329510348' />
<nd ref='5329510364' />
<nd ref='5329510331' />
<nd ref='5329510322' />
<nd ref='5329508418' />
<nd ref='5329510351' />
<nd ref='5329510360' />
<nd ref='5329510663' />
<nd ref='5329510698' />
<nd ref='5329510730' />
<nd ref='6453015430' />
<nd ref='7264736136' />
<nd ref='5329510752' />
<nd ref='5329510751' />
<nd ref='5329510674' />
<nd ref='5329510688' />
<nd ref='5329510408' />
<nd ref='5329510709' />
<nd ref='5329510414' />
<nd ref='5329510382' />
<nd ref='5329510384' />
<nd ref='5329510795' />
<nd ref='5329510794' />
<nd ref='5329510656' />
<nd ref='5329510358' />
<nd ref='5329510359' />
<nd ref='5329510653' />
<nd ref='5329510381' />
<nd ref='5329510654' />
<nd ref='6819115285' />
<nd ref='992691843' />
<tag k='highway' v='secondary' />
<tag k='name:en' v='Ron Nachman' />
<tag k='name:etymology:wikidata' v='Q361323' />
<tag k='oneway' v='yes' />
<tag k='ref' v='4775' />
<tag k='surface' v='asphalt' />
</way>
how can I check which node is the source of the way and which is the destination?
All ways in the OpenStreetMap database have a direction. This is defined by the order of the referenced nodes: They are ordered from the start to the end of the way.
By itself, this direction has no meaning – it simply depends on where the mapper has started drawing. But certain tags on ways refer to the way's direction. If those tags appear on a way, you need to take the direction into account.
Examples for these tags appear in the documentation on the OSM wiki:
If you're creating edges for routing, you should also consider ...