Knicks center Mitchell Robinson scuffles with Nets forward Danny Wolf...

Knicks center Mitchell Robinson scuffles with Nets forward Danny Wolf in the first half of an NBA basketball game at Barclays Center on Friday. Credit: Kathleen Malone-Van Dyke

Mike Brown’s logic was sound. Or at least, it was sound mathematically.

If Team A beats Team B and Team B beats Team C, then Team A ought to be able to beat Team C. Right?

Still, while the transitive property of equality often works in sports, there really seemed to be a slim chance of it holding up with the example Brown was giving before the Knicks played the Nets on Friday night in Brooklyn.

“Five or six games ago, these guys beat Detroit I think in Detroit,” said Brown, whose team is 0-3 against the Pistons this season. “They’re in the NBA. They have a great young coach. And anything can happen.”

Well, anything almost did.

The Knicks were incredibly lucky to walk away with a 93-92 victory over a fired-up Nets squad on Friday night.

They had no business being in a close game with a team like the Nets that had won only twice in the last 17 games and was playing without their top scorer, Michael Porter Jr. They had no business being in a game that wasn’t decided until Ben Saraf missed a desperation shot at the buzzer.

Few at Barclays Center — including possibly the sprinkling of Nets fans in a crowd heavy with Knicks fans — expected  the Nets to come this close to beating a team that considers itself a contender.

The Knicks entered the game with 13 straight wins against the Nets, including a 120-66 victory on Jan. 21 that set a franchise record for largest margin of victory. That’s why it was so stunning to see how flat the Knicks came out in the first quarter, scoring  14 points and shooting  21%.

The Knicks have struggled to start games strong all season, but this set a season low for first-quarter points. The Knicks continued to struggle offensively in the second quarter, which featured a heated exchange between the Knicks' Mitchell Robinson and the Nets' Zaire Williams and Danny Wolf.

“I thought we were real lackadaisical with the basketball,” Brown said. “We had some turnovers to start the game. We had 13 at halftime and we ended the game with 22. That’s not a good ingredient to have when you are trying to get a road win no matter who you are playing.

“If your approach is not what it is and the other team feels it, anybody can get beat at any time on any level.”

It was a dismal performance considering these are two teams headed in opposite directions, which isn’t to say both don’t have big-time aspirations. The Nets (17-53), who made five first-round lottery picks last year, have a lot riding on getting a high pick this season. Heading into Friday night’s game, their winning percentage of .246 was the third worst in the NBA, ahead of only Washington and Indiana. Every loss moves them closer to their goal.

The Knicks (46-25) entered the season talking like a contender. After some significant and weird ups and downs, they are heading into the home stretch of the regular season with some signs that they can make some noise in the postseason — which is why every one of their final 11 games matter.

The Knicks are playing decent basketball. They have won five straight and nine of their last 12. But what’s most important is what could happen above them in the Eastern Conference.

Cade Cunningham is out for at least two weeks and most likely more after  suffering a collapsed lung. The Pistons' remaining schedule is tough and Cunningham is basically most of their offense. It’s possible that Detroit (50-19), which has been at the top of the conference all season, will lose the top seed to the No. 2 Celtics (46-23), who are looking pretty formidable now that Jayson Tatum is back.

That’s why it’s so important for the Knicks to keep winning and hold on to the third seed over Cleveland, which trailed them by two games entering Friday. As much as the Knicks have struggled against the Pistons, losing to them by an average of 28.0 points this season, Detroit is inexperienced in the playoffs and no one knows how long it will take to reintegrate Cunningham.

The Celtics, with Tatum, are a known entity, one that the Knicks needed some luck to get past last season. Avoiding the Celtics until the Eastern Conference finals sounds like a solid plan, which means picking up every possible win and not overlooking even the most downtrodden of opponents.

“You gotta make sure that you respect each game individually for your next opponent,” Brown told his team on Thursday. “It doesn’t matter what the record is, they’re in the NBA. Anything can happen at any time.”

Yes, it can, as we saw with the Knicks’ poor play Friday.

SUBSCRIBE

Unlimited Digital AccessOnly 25¢for 6 months

ACT NOWSALE ENDS SOON | CANCEL ANYTIME