The southern terminus of the railway line to Hogwarts is at Kings Cross station in London, a Muggle railway station, albeit using a magical platform inaccesible to Muggles (except perhaps parents of Muggleborns seeing their children off to school). How does the line to Hogwarts fit in with the Muggle rail network? Is it a completely separate line, or does it share tracks with Muggle trains and the Hogwarts Express is able to magically avoid collisions (and detection)?
It's never conclusively stated.
We don't have an awful lot of information in canon about the train line itself. Pottermore does tell us some of the history behind the Hogwarts Express.
A daring and controversial solution to the thorny problem [of transporting students] was finally suggested by Minister for Magic Ottaline Gambol, who was much intrigued by Muggle inventions and saw the potential in trains. Where exactly the Hogwarts Express came from has never been conclusively proven, although it is a fact that there are secret records at the Ministry of Magic detailing a mass operation involving one hundred and sixty-seven Memory Charms and the largest ever mass Concealment Charm performed in Britain. The morning after these alleged crimes, a gleaming scarlet steam engine and carriages astounded the villagers of Hogsmeade (who had also not realised they had a railway station), while several bemused Muggle railway workers down in Crewe spent the rest of the year grappling with the uncomfortable feeling that they had mislaid something important.
(Pottermore, "The Hogwarts Express").
And the history of wizards using King's Cross.
When Ottaline Gambol commandeered a Muggle train to serve as the new mode of transport for Hogwarts students, she also had constructed a small station in the wizarding village of Hogsmeade: a necessary adjunct to the train. The Ministry of Magic felt strongly, however, that to construct an additional wizarding station in the middle of London would stretch even the Muggles’ notorious determination not to notice magic when it was exploding in front of their faces.
It was Evangeline Orpington, Minister from 1849-1855, who hit upon the solution of adding a concealed platform at the newly (Muggle) built King’s Cross station, which would be accessible only to witches and wizards.
(Pottermore, "King's Cross Station").
This tells us rather more about the modification of the station and the train for magical use than the trainline itself.
Both the options presented in the question are feasible. Either the Hogwarts Express connects onto a Muggle trainline shortly after departing from King's Cross or it uses a special, unique line the whole way.
In defence of the first theory, it makes sense that if they were to add an extra platform to a station then they would want to use the station's infrastructure (its tracks) as well. It would be easier and more convenient to use the trainlines which had already been installed by Muggles, and simply to add a concealed junction somewhere inconspicuous not too far from the station. The train doesn't need to be made invisible or disguised. It looks just like an old Muggle train anyway, which was partly why it was picked as a mode of transport in the first place. Bystanders would just think that it's a rustic period train being given a rare outing. As for avoiding collisions, we know that the Hogwarts Express was originally a Muggle train, although it was given magical alterations.
The Hogwarts Express underwent several magical modifications before the Ministry approved it for school use.
(Pottermore, "The Hogwarts Express").
These alterations would presumably be able to find a way round that problem, perhaps by magically changing the signals to give the Hogwarts Express clear passage.
Nevertheless, I'm more convinced by the second theory - that the Hogwarts Express uses its own track to get to Hogwarts. There are two reasons supporting this. Firstly, as the Pottermore article says, Hogsmeade had its own station built as part of the Gambol scheme. As Hogsmeade is a wizards-only village the Ministry would want to keep Muggle trains well away, to protect the Statute of Secrecy. I think that Ministry officials would prefer to have a separate line rather than run the risk that a Muggle train would stumble into Hogsmeade accidentally.
Secondly, no other Muggle train stations are ever mentioned on the train journey. Admittedly, much of the narrative is focussed elsewhere and descriptions of the journey tend to be along the lines of 'The train rumbled further northwards'. Nevertheless, the landscape tends to be largely rural after they get out of London.
While they had been talking, the train had carried them out of London. Now they were speeding past fields full of cows and sheep. They were quiet for a time, watching the fields and lanes flick past.
(Philosopher's Stone, Chapter 6, The Journey from Platform Nine and Three-Quarters).
The Hogwarts Express moved steadily north and the scenery outside the window became wilder and darker while the clouds overhead thickened.
(Prisoner of Azkaban, Chapter 5, The Dementor).
The train rattled onwards, speeding them out into open country.
(Order of the Phoenix, Chapter 10, Luna Lovegood).
Only on one occasion is a city even mentioned, and even then the picture is largely rural.
They made regular checks on the train as they flew further and further north, each dip beneath the clouds showing them a different view. London was soon far behind them, replaced by neat green fields which gave way in turn to wide, purplish moors, villages with tiny toy churches and a great city alive with cars like multi-coloured ants.
(Chamber of Secrets, Chapter 5, The Whomping Willow).
I've travelled on the East Coast line from King's Cross to Scotland literally dozens of times. It goes through plenty of cities - Peterborugh, York, Durham, Newcastle and Edinburgh to name just a few. If the Hogwarts Express went through these stations then I'd expect to hear at least one mention of the train passing through big cities or speeding through Muggle platforms. This never happens, which suggests to me that the Hogwarts Express has its own dedicated line. This line would presumably be hidden from the Muggles to avoid awkward questions from Network Rail.